Iframe / Javascript Check if Youtube Video Ends

后端 未结 3 2118
北恋
北恋 2020-12-18 11:22

Right now I have youtube videos loading in via Iframe. Is it even possible to check if the youtube video ended when it is in that sort of state? Can I use OnStateChange() t

3条回答
  •  借酒劲吻你
    2020-12-18 11:40

    you can detect the end of the video like so:

    function onPlayerStateChange(event) {
      if (event.data == YT.PlayerState.ENDED){
        // your code to run after video has ended
      }
    }
    

提交回复
热议问题