【问题标题】:Create plugin in Videojs 4.0在 Videojs 4.0 中创建插件
【发布时间】:2013-06-17 15:58:05
【问题描述】:

我已经为 4.0+ 版本创建了一个这样的插件

function examplePlugin(options) {
    this.on('play', function(e) {
    console.log('playback has started!');
    });

    vjs.NewPlayButton = vjs.Component.extend({
        init: function(player, options){
            vjs.Component.call(this, player, options);
            console.log('init New play btn');
        }
    });  

};

并像

一样注册了插件
vjs.plugin('examplePlugin', examplePlugin);

我已经在 html 之上包含了库,比如

<script src="js/video.dev.js"></script>
<script src="js/exampleplugin.js"></script>  

在我看到的很多例子中,我们可以通过当前视频实例初始化插件,我想在所有实例中添加这个插件,这将是动态的。

所以就像它必须添加的默认组件一样。现在我没有得到任何日志。

有没有办法初始化它?即使不是作为插件,我只是想再添加一个自定义组件。

【问题讨论】:

    标签: javascript html html5-video video.js


    【解决方案1】:

    插件会自动添加到播放器原型中,但据我所知,无法自动初始化它们。我认为您想要的是将组件添加到默认组件列表中。

    https://github.com/videojs/video.js/blob/v4.0.4/src/js/core.js#L82

    你可以试试这样的:

    videojs.options.children.newPlayButton = {};

    (除了您用于制作 videojs.NewPlayButton 的代码)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-02
      • 1970-01-01
      • 1970-01-01
      • 2022-06-19
      • 2018-07-18
      相关资源
      最近更新 更多