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?
欢迎选择我的课程,让我们一起见证您的进步~~
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.
Traverse all videos, pause them all and then open the current one
var cur_video;
Send me a demo so that if anyone encounters it in the future, you can refer to it.
Traverse all videos, pause them all and then open the current one