How to autoplay YouTube videos with the YouTube API

Hi everyone,

https://github.com/gsu-library/sirenia/issues/116

in this discussion about an error with the YouTube player not being attached to the DOM, the following code is discussed.

     // Use the event handler as a reference instead of the player variable.  This ensures
    // that the player object is loaded before trying to reference it, preventing the 'player is undefined error'
     function onPlayerReady(event) {
     var ytPlayer = event.target;
     ytPlayer.playVideo();
     }

You can use this to test it.
http://textadventures.co.uk/forum/quest/topic/npjtw2iy5uwjb-lywymjqg/clean-code-working-youtube-video-player-with-api

this is a simple example of how to autoplay a video on load with the YouTube Ifram API.

This answers one of my first questions about how to play videos through Quest.

"-" egoproctor


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums