代码之家  ›  专栏  ›  技术社区  ›  Alocus

在Vuejs组件中使用videojs vr

  •  0
  • Alocus  · 技术社区  · 7 年前

    我正在尝试使用 videojs-vr ,我通过npm安装在Vuejs组件中。出现了一个错误:

    TypeError: videojs is not a function
    at VueComponent.mounted (VR.vue?d2da:23)
    at callHook (vue.esm.js?65d7:2701)
    at Object.insert (vue.esm.js?65d7:3588)
    at invokeInsertHook (vue.esm.js?65d7:5541)
    at VueComponent.patch [as __patch__] (vue.esm.js?65d7:5744)
    at VueComponent.Vue._update (vue.esm.js?65d7:2460)
    

    我试着 进口 要求 图书馆。我使用npm库的方式一定有问题。请帮忙。

    <template>
      <div class="videojs-vr" style="width: 100%; height:100%;">
        <video id="videojs-vr-player" class="video-js vjs-default-skin" controls>
          <source src="./static/videos/sample.mp4" type="video/mp4">
        </video>
      </div>
    </template>
    <script>
    var videojs = require('videojs-vr');
    // import videojs from 'videojs-vr';
    
    export default {
      name: 'videojs-vr',
      mounted() {
        var player = videojs('videojs-vr-player');
        player.mediainfo = player.mediainfo || {};
        player.mediainfo.projection = '360';
        // AUTO is the default and looks at mediainfo
        player.vr({projection: 'AUTO', debug: true, forceCardboard: false});
      },   
    };
    </script>
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   thanksd thibaut noah    7 年前

    您需要首先要求 video.js 并将该引用设置为 videojs 变量然后,您只需要 videojs-vr

    Here's the example from the documentation:

    var videojs = require('video.js');
    
    // The actual plugin function is exported by this module, but it is also
    // attached to the `Player.prototype`; so, there is no need to assign it
    // to a variable.
    require('videojs-vr');
    
    var player = videojs('my-video');
    
    player.vr({projection: '360'});