There is an Autoplay feature on YouTube which plays the next recommended video.
How do I go about enabling this in an embedded YouTube player?
The YouTube API here explains an autoplay function but this isn't the same. The feature they describe is automatically playing the video as soon as the web page is loaded.
Is there any way to implement the Autoplay feature found on YouTube in an embedded video frame?
as i understand the idea is to have the same behaviour using embedded youtube (YouTube Iframe-API) as using the normal youtube.com with autoplay set to true.
the only way i found so far is to fetch a videoId through an api call as described here: https://stackoverflow.com/a/19732072/10956686 and then use player.loadVideoById() after PlayerState.ENDED event is fired.
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.ENDED && !done) {
player.loadVideoById(myFetchedNextVideoId);
}
}
but this could lead to a lot of API quota usage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With