Just finished a little experiment to load flv’s from YouTube into your own swf files…
Every YouTube video has a unique id. You can find this id, using the public YouTube API. However, you’ll need more than this simple id to play the video’s in your own flash/flex/… application.
If you take a closer look to the source code on a YouTube page, playing a video, you will find something like this in the source code:
1 2 3 4
You can see it adds some more variables after the video_id parameter. These parameters are needed to retrieve the flv itself. What you could do in flash, is retrieve the html source of a video with the given video_id, so a search in the retrieved source and retrieve the full video id. If you have a video object on the stage, you could then play the video using this object:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
I had to use the NetStream object on a video object on stage, for some reason I couldn’t get this to work with the default FLVPlayback component… Also, the width and height of the movie aren’t specified in the flv metadata from youtube, so I retrieved those values another way (onStatus event, when Buffer is empty) If you run it outside of the authoring environment, you will also get a security sandbox warning… Maybe somebody knows a workaround for this in this application?