Steps to Reproduce the Issue:
- Go to
- Enter
sMqNFAU0tOw
(or any other Youtube video ID) in the Video Playlist - Click on Play Videos!
- The JavaScript console should display an error message like
Uncaught TypeError: undefined is not a function
This error is originating from the following code snippet, where I am attempting to use Google's JavaScript Youtube API to play Youtube videos in a sequence:
var atts = { id: "myytplayer" };
var params = { allowScriptAccess: "always" };
swfobject.embedSWF(thisurl, "playerdiv", "425", "356", "8", null, null, params, atts);
var ytplayer = document.getElementById("myytplayer");
ytplayer.playVideo(); // <----- problematic line
}
(API documentation: https://developers.google.com/youtube/js_api_reference)
I suspect that the issue arises because the playVideo
method is called before the myytplayer
element is fully created by the swfobject.embedSWF
function. Is this the root cause of the problem?