Detect if HTML5 Video element is playing

后端 未结 16 2472
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 00:43

I\'ve looked through a couple of questions to find out if an HTML5 element is playing, but can\'t find the answer. I\'ve looked at the W3 documentation and it has an event n

16条回答
  •  眼角桃花
    2020-11-29 01:07

    var video_switch  = 0;
    
    function play() {
    
        var media = document.getElementById('video');
    
        if (video_switch == 0)
        {
            media.play();
            video_switch = 1;
        }
        else if (video_switch == 1)
        {
            media.pause();
            video_switch = 0;
        }
    }
    

提交回复
热议问题