Search code examples
actionscript-3youtube-apiflash-builder

How to play a youtube video with a tag in Flash Builder


I am using Google code: https://code.google.com/p/gdata-samples/source/browse/trunk/ytplayer/actionscript3/com/google/youtube/examples/AS3Player.as to play a YouTube video. I want to add the tag

?rel=0

to the end of a url to prevent YouTube adds appearing at the end of the video. However, when I concatenate the tag, the following event handler no longer works:

playerLoader.content.addEventListener("onReady", onPlayerReady);

For example, the following fails:

playerLoader.load("http://www.youtube.com/v/VIDEO_ID?v=wzS8ANZBRNo?rel=0");

but this works:

playerLoader.load("http://www.youtube.com/v/VIDEO_ID?v=wzS8ANZBRNo");

Can anyone suggest a way to deal with this?


Solution

  • ? is used to denote the beginning of your URL vars, & is used to append subsequent vars.

    Change:

    playerLoader.load("http://www.youtube.com/v/VIDEO_ID?v=wzS8ANZBRNo?rel=0");

    to

    playerLoader.load("http://www.youtube.com/v/VIDEO_ID?v=wzS8ANZBRNo&rel=0");