Another page uses video.js to initialize multiple video tags. Now when a video tag is played, if there is a video tag playing at this time, it will be paused. How to deal with it?
某草草2017-05-19 10:20:57
var cur_video;
var setup = function(videoEl, options) {
videoEl.bigPlayButton.controlTextEl_.textContent=videoEl.el().getAttribute('duration');
videoEl.on("play",function(){
if(cur_video && cur_video != videoEl)cur_video.pause();
cur_video = videoEl;
})
videoEl.on("pause",function(){
if(cur_video==videoEl)cur_video==null;
})
};
videojs.hook('setup', setup);
var videos = [
videojs('example_video_1'),
videojs('example_video_2'),
videojs('example_video_3')
]
Send me a demo so that if anyone encounters it in the future, you can refer to it.