Can Javascript detect when an embedded Youtube video has ended?

前端 未结 2 2016
遥遥无期
遥遥无期 2021-01-27 04:25

I have a div containing a video. The background of the div features a fake \"play\" button, which I\'ve designed to use as the play button instead of Youtube\'s standard video

2条回答
  •  旧时难觅i
    2021-01-27 04:41

    Here's what you're looking for:

    http://jsfiddle.net/7Gznb/

    // when video ends
        function onPlayerStateChange(event) {        
            if(event.data === 0) {            
                alert('done');
              //do something here
    
            }
    

    That's the Youtube API by the way

提交回复
热议问题