Get Multiple Embedded Youtube Videos to Play Automatically in Sequence

前端 未结 6 2067
遇见更好的自我
遇见更好的自我 2021-02-02 03:19

Is there any simple way to have multiple embedded YouTube videos on a page and have them start playing as soon as the page is opened and when the first one finished have the sec

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 03:59

    I am not good at javascript. But I have some similar question before.

    you could referece

    judgement the first video is finished then run the second. you could set 2 functions.


    then

    function onPlayerStateChange(event) {        
                if(event.data === 0) {          
                    $('#player2-param').attr('value','http://www.youtube.com/v/OdT9z-JjtJkautoplay=1');//jquery
                    $('#player2-embed').attr('src','http://www.youtube.com/v/OdT9z-JjtJkautoplay=1');//jquery
    
                }
            }
    

    hope this could help you and write some nicer code, thanks.

提交回复
热议问题