search

Home  >  Q&A  >  body text

Problem with video.js - Stack Overflow

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?

天蓬老师天蓬老师2780 days ago790

reply all(2)I'll reply

  • 某草草

    某草草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.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-19 10:20:57

    Traverse all videos, pause them all and then open the current one

    reply
    0
  • Cancelreply