1:官网下载
2:扩充video功能---plugins.md插件
1:新建一个函数
<span style="background-color: rgb(255, 255, 255);"><span style="background-color: rgb(0, 102, 0);"> function examplePlugin(options) {
this.on('play', function(e) {
console.log('playback has started!');
});
};</span></span>
2:把函数定义为插件
<span style="background-color: rgb(255, 255, 255);"><span style="background-color: rgb(0, 102, 0);"> videojs.plugin('examplePlugin', examplePlugin);</span></span>
3:应用插件
方法一:
<span style="background-color: rgb(255, 255, 255);"><span style="background-color: rgb(0, 102, 0);"> videojs('vidId', {
plugins: {
examplePlugin: {
exampleOption: true
}
}
});</span></span>
方法二:
<span style="background-color: rgb(255, 255, 255);"><span style="background-color: rgb(0, 102, 0);"> var video = videojs('cool-vid');
video.examplePlugin({ exampleOption: true });</span></span>
一个关于新建插件的例子:
新建一个按钮并点击时候视频回到开头并停止
我们在上面的examplePlugin()函数中添加代码
<span style="background-color: rgb(255, 255, 255);"><span style="background-color: rgb(0, 102, 0);"> function examplePlugin(options) {
var backplayBtn = document.createElement('div');
backplayBtn.className = 'vjs-backplay-button vjs-menu-button vjs-control';
backplayBtn.innerHTML =
'<div>'
+ '<i class="fa fa-step-backward&