Check if a HTML5 video element is playing

前端 未结 1 2096
梦毁少年i
梦毁少年i 2021-02-13 04:38

How can I check status of a HTML5 vide element? I need to toggle play/pause the video element.

相关标签:
1条回答
  • 2021-02-13 05:06

    There are few methods like below,

    var myVideo=document.getElementById("video1"); 
    if (myVideo.paused) {
      myVideo.play(); 
    }
    else { 
      myVideo.pause(); 
    } 
    

    have a look at complete working example here.

    0 讨论(0)
提交回复
热议问题