Problem with video.js - Stack Overflow
天蓬老师
天蓬老师 2017-05-19 10:18:57
0
2
778

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?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
某草草

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template