Autostart next video in YouTube built-in player

YouTube has an autorun feature that plays the next recommended video.

How do I enable this in the built-in YouTube player?

The YouTube API here explains autostart, but it’s not the same. The feature they describe automatically plays the video as soon as the web page loads.

Is there a way to implement the autostart function on YouTube in the integrated video frame?

+7
source share
2 answers

, , YouTube (YouTube Iframe-API), youtube.com , true.

, , videoId API, : fooobar.com/questions/227889/... player.loadVideoById() PlayerState.ENDED.

    function onPlayerStateChange(event) {     
        if (event.data == YT.PlayerState.ENDED && !done) {        
            player.loadVideoById(myFetchedNextVideoId);
        }       
    }

API.

0

YouTube

<iframe width="420" height="315" src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1"> </iframe>

-2

All Articles