« Gmail Paper | Main | Google Talk user-interface annoyance »

April 02, 2007

Constructing YouTube FLV URL on client-side without any server-side script

It seems, there is a easier way of constructing YouTube! FLV URL on client-side without using any server-side script.

We need get the YouTube video_id from any of following places:-

Then, construct a URL like this: http://www.youtube.com/v/V3BsjxDZJM0

Above URL is used in YouTube embed-code. It is basically a server-side redirection that points to YouTube Player (.swf). Above redirects (server-side) to following URL:-
http://www.youtube.com/p.swf?video_id=V3BsjxDZJM0&eurl=&iurl=http%3A//sjc-
static12.sjc.youtube.com/vi/V3BsjxDZJM0/2.jpg&t=OEgsToPDskKzlTMEFZ1jOh40Xc3qOxzQ

As you can see in above URL, it contains "t" param (in red), which is what we need along with video_id to construct YouTube video (FLV) URL, YouTube FLV URL would look like this:-
http://www.youtube.com/get_video.php?video_id=V3BsjxDZJM0&
t=OEgsToPDskKzlTMEFZ1jOh40Xc3qOxzQ

You can check out code below to figure out things your own. You can also check out the example-app.

Flex 2.0/ActionScript 3.0 example:-


<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
	creationComplete="onAppCreationComplete ()"
	horizontalAlign="left"
	width="800"
	height="350">
	<mx:Script>
		<![CDATA[
			import flash.net.*;
			import flash.events.*;
			import flash.display.*;
			private var loader:Loader;
			private var abortId:uint;
			private function onAppCreationComplete ():void
			{
				loader = new Loader ();
			}
			private function startLoading ():void
			{
				var req:URLRequest = new URLRequest ("http://www.youtube.com/v/3IcwG0jUFxU");
				loader.contentLoaderInfo.addEventListener(Event.INIT, handlerLoaderInit);
				loader.load(req);
				logMessage ("Loading YouTube URL..");
			}
			private function handlerLoaderInit (event:Event):void
			
			{
				logMessage ("Loaded, processing: " + loader.contentLoaderInfo.url);
				var urlVars:URLVariables = new URLVariables ();
				urlVars.decode (loader.contentLoaderInfo.url.split("?")[1]);
				logMessage ("Processed:-");
				logMessage ("\t\t video_id:" + urlVars.video_id);
				logMessage ("\t\t t param:" + urlVars.t);
				logMessage ("\t\t thumbnail-url:" + urlVars.iurl);
				var flvURL:String = constructFLVURL (urlVars.video_id, urlVars.t);
				logMessage ("YouTube FLV URL: " + flvURL);
				playVideo (flvURL);
				logMessage ("Started Playing Video...");
				loader.unload(); 
			}
			private function constructFLVURL (video_id:String, t:String):String
			{
				var str:String = "http://www.youtube.com/get_video.php?";
				str += "video_id=" + video_id;
				str += "&t=" + t;
				return str;
			}
			private function playVideo (url:String):void
			{
				player.source = url;
				player.play();
			}
			private function logMessage (message:String):void
			{
				outputText.text += message + "\n";
				trace (message);
			}	
		]]>
	</mx:Script>
	<mx:HBox width="100%">
		<mx:Label text="YouTube Video URL:"/>
		<mx:TextInput id="urlText" width="300"/>
		<mx:Button label="Submit" click="startLoading ()" id="submitButton"/>
	</mx:HBox>
	<mx:HBox width="100%">
	<mx:VBox height="100%">
		<mx:Label text="VideoDisplay:"/>
		<mx:VideoDisplay width="320" height="240" id="player"/>
	</mx:VBox>
		<mx:VBox height="100%" width="100%">
			<mx:Label text="Output:-"/>
			<mx:TextArea id="outputText" width="100%" height="100%"/>
		</mx:VBox>
	</mx:HBox>
</mx:Application>


ActionScript 2.0 code-snippet:-


createEmptyMovieClip ("mc", getNextHighestDepth ());
var _mcl:MovieClipLoader = new MovieClipLoader ();
_mclListener = new Object ();
_mclListener.onLoadStart = function (target:MovieClip)
{
trace ("The URL is: " + target._url);
var _lv:LoadVars = new LoadVars ();
_lv.decode (target._url.split ("?")[1]);
trace ("t param: " + _lv.t);
trace ("video_id: " + _lv.video_id);
trace ("thumbnail: " + _lv.iurl);
trace ("flv url: " + constructFLVURL (_lv.video_id, _lv.t));
_mcl.unloadClip (target);
};
function constructFLVURL (videoId:String, t:String):String
{
var str:String = "http://www.youtube.com/get_video.php?";
str += "video_id=" + videoId;
str += "&t=" + t;
return str;
}
_mcl.addListener (_mclListener);
_mcl.loadClip ("http://www.youtube.com/v/3IcwG0jUFxU", mc);

 [1] Flash clients would require server-side proxy because YouTube changed crossdomain.xml sometimes back.


Posted by Abdul Qabiz at April 2, 2007 05:28 PM

Comments

as3 example works fine :)

is it possible to run AS2 code with video playback component : myVideoPlayback.contentPath = constructFLVURL (_lv.video_id, _lv.t)?

Posted by: kbsdkz at April 16, 2007 07:55 PM

simply brilliant, but can´t be done a function that does everything with one?

I have modified this so that she takes "target" but, since everything could be made simultaneously?

createEmptyMovieClip ("mc", getNextHighestDepth ());

var _mcl:MovieClipLoader = new MovieClipLoader ();
_mclListener = new Object ();

_mcl.addListener (_mclListener);

_mcl.loadClip ("http://www.youtube.com/v/3IcwG0jUFxU", mc);


_mclListener.onLoadStart = function (target:MovieClip){

trace ("flv url: " + constructFLVURL (target));

salida = "oeeeoeoeoeoe: " + constructFLVURL (target);

_mcl.unloadClip (target);

};



//My Modification
function constructFLVURL (dir):String {

var _lv:LoadVars = new LoadVars ();

_lv.decode (dir._url.split ("?")[1]);

trace ("The URL is: " + target._url);

trace ("t param: " + _lv.t);

trace ("video_id: " + _lv.video_id);

trace ("thumbnail: " + _lv.iurl);

var str:String = "http://www.youtube.com/get_video.php?" + "video_id=" + _lv.videoId + "&t=" + _lv.t;

return str;

}

Posted by: Antares at April 30, 2007 08:19 PM

It works if you open it from your harddisk, but when I load it from the internet, the values are undefined?

Also, could you post the source so I (and possible other people) can see how you did it?

Thanks.

Posted by: NeWbY at May 1, 2007 06:34 PM

I'm using your AS2 example and I can't get the video to load into flash. If I understand your article, I'm supposed to use a PHP proxy for this, but I haven't found one that works. (I tried this one but didn't have any luck) Any help to point me in the right direction is greatly appreciated.

..k..

Posted by: Kyle at May 1, 2007 09:07 PM

@NeWbY: It works online, I checked it...

You can see the working example: http://www.abdulqabiz.com/files/YouTube_Client_side_demo/YouTubeClientSideDemoFlex.html

Source for this example is already in this page, check out the post above.

@Kyle: You don't need a php-proxy if you use the approach mentioned in this post. You can see a working AS2 example here:

http://www.abdulqabiz.com/files/YouTube_Client_side_demo/youtube_flv_url_test_as2.swf

Fla file: http://www.abdulqabiz.com/files/YouTube_Client_side_demo/youtube_flv_url_test_as2.fla

Hope that helps...

-abdul

Posted by: Abdul Qabiz at May 2, 2007 11:08 AM

The working example uses Flex, and apparently that works normally. But using the AS2 code still does not work.
The example you posted above (youtube_flv_url_test_as2.*) both return 'undefined' (for the parameters) to me when I run it, no matter if I run it from your website, my harddisk or localhost.

Might be just me that I don't understand the concept though, but I'd be happy when it works here :)

Posted by: NeWbY at May 2, 2007 05:14 PM

@NeWbY:

Thanks, I just noticed it doesn't work for IE for some reason.. I would check it out..

I am running it FireFox 2.x and it works fine for me... I think, it should work for you also..

I got confirmation from a friend that it works for her also..

Thanks

-abdul

Posted by: Abdul Qabiz at May 2, 2007 06:20 PM

Could it be that IE only returns 'http://www.youtube.com/v/3IcwG0jUFxU' to the swf file, because thats the actual URL and doesnt waits for the redirect or something?

Posted by: NeWbY at May 3, 2007 05:46 PM

Hey Abdul,

Thanks for responding :) I can confirm that it DOES work in FireFox 2.x as well as Opera 9. Here's a screenshot of all 3 browsers.

I ended up using a php proxy, but only because my project required the use of Zinc, which forces you to use IE as the default web browser engine... which has the problems mentioned above.

Best,

..k..

Posted by: Kyle at May 3, 2007 08:20 PM

Has anyone had luck yet with Internet Explorer and this approach or am I stuck relying on my server side logic to give me my flv stream uri.

So it seems YouTube will provide the video id and 't' code for videos when requesting by tag (REST api), but they don't have an api call one can use to simply convert a youtube video url, to flv stream url? Seems like that would help everyone out of hacking around (coupled with a reasonable terms of use perhaps)...

In my particular use case, I wouldn't mind embedding YouTube's stock player, however there is no reliable way (it seems) in Flash to pull the plug on YouTube's NetStream instance. e.g. after embedding their player inside another SWF - when it comes time to unloadClip/removeMovieClip, the audio stream continues. So I'm stuck rendering the flv directly as others are doing on this thread.

Posted by: Corey at May 7, 2007 09:31 PM

@Corey > I had a look at the youtube player, you stop the audio stream (for example, before loading a new movie into your player) by simply using flash's sound class.

var soundController:Sound = new Sound();
soundController.stop();

Posted by: Pete at May 10, 2007 06:42 PM

Unfortunately it doesn't appear to be that simple. I use the MovieClipLoader so that I can reliably downscale the YouTube player. But once I do that, I run into this documented issue with the stream not being destroyed properly:
(http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a360ede)

And when using a straight loadMovie, the Sound object does in fact stop playing stream, but within Firefox (MAC at least), attempting to replay the same exact video again in the same session is problematic -- the video, (even upon restarting Firefox) refuses to stream, and will only play again after fully downloading.

Nothing can ever be simple these days (nor bug free).

If you have any suggestions feel free to drop me a message on my blog and I'll get back to you. Otherwise, apologies for the off topic digression.

Posted by: Corey at May 14, 2007 09:09 PM

I cant play video in your AS2 example.
and is it your YouTubeClientSideDemoFlex is done by flash cs3 or flash 8

Posted by: Andy at May 18, 2007 12:35 AM

i cannot play video in AS2, its always apper this error:

*** Security Sandbox Violation ***
SecurityDomain 'http://www.youtube.com/p.swf?video_id=3IcwG0jUFxU&eurl=http%3A//www.youtube.com/v/3IcwG0jUFxU&iurl=http%3A//img.youtube.com/vi/3IcwG0jUFxU/2.jpg&t=OEgsToPDskJRMVlkIy0HLHFpn8x3JaKu' tried to access incompatible context 'file:///C|/Users/AnDY/Desktop/youtube%5Fflv%5Furl%5Ftest%5Fas2.swf'

Posted by: Andy at May 18, 2007 01:27 AM

Hey Abdul,

Thanks for your AS2 code, I was finally able to get it working displaying Youtube videos. Muchos Gracias! (Using Firefox 1.5.0.11 on XP for those whom stated had trouble)

I did have a question though. How difficult would it be to modify this AS2 code to stream other video flv like Revver, Bliptv, and maybe eventually Joost etc.?

Posted by: Dow at May 19, 2007 07:41 PM

Hey Abdul,

Thanks for your AS2 code, I was finally able to get it working displaying Youtube videos. Muchos Gracias! (Using Firefox 1.5.0.11 on XP for those whom stated had trouble)

I did have a question though. How difficult would it be to modify this AS2 code to stream other video flv like Revver, Bliptv, and maybe eventually Joost etc.?

Posted by: Dow at May 19, 2007 09:08 PM

> I did have a question though. How difficult would
> it be to modify this AS2 code to stream other
> video flv like Revver, Bliptv, and maybe
> eventually Joost etc.?

Revver and BlipTV can be played using AS2 code, you would need to write the logic. You can use Revver API or BlipTV's RSS feed to do that...

-abdul

Posted by: Abdul Qabiz at May 21, 2007 12:17 PM

Abdul:

testing your code for loading flv from youtube, i got stupid and created an iteration of part of the process, and was able to give one of my youtube videos viewership of 20,000+. It won an honor for most viewed in a 24 hr period.

Then I gave another video 5,000+ hits. Unfortunately for me, i was logged into youtube at the time and as a result my profile now has me as having viewed 5,000+ videos. now im apprehensive because i dont want google to contact me or, worse, remove the ability to access the t parameter! crime does not pay and let that be a lesson to the kids out there, seriously.

anyway my real vocation, the one with a future, is to build an RIA video player able to integrate videos from youtube, google video, blinkx, brightcove, and, not least, locally hosted, etc. into the same playlist(s).

abdul, serious serious thanks because your blog and the concepts you expose in it have been instrumental in my development of this product. pure brilliance.

Regards,
Doon Rothmani

Posted by: DoonRothmani at May 27, 2007 10:45 AM

hi Andy,
how did you get by this sandbox violation problem.
i get the same error

cheers
uri

Posted by: uri at May 27, 2007 02:52 PM

@Andy, uri: That security-error can be ignored or you can put a System.security.allowDomain ("youtube.com") in your file.

I am sure, youtube player doesn't have anything that can cause any damage to your swf, if you do that :)

@DoonRothmani:

> anyway my real vocation, the one with a future,
> is to build an RIA video player able to
> integrate videos from youtube, google video,
> blinkx, brightcove, and, not least, locally
> hosted, etc. into the same playlist(s).

You can look at the Media RSS standard and do it. We are doing it in Mixercast.com, where you can pull videos from different sources (youtube, google-video, metacafe, digitalmotion, blip.tv etc).

There are sites which don't provide FLV path which you can find through workaround (like in Youtube case), though I feel these sites can atleast provide preview (shorter length) flv files so I posted something about it here:-

http://www.abdulqabiz.com/blog/archives/general/media_rss_with_diffe_1.php

> abdul, serious serious thanks because your blog
> and the concepts you expose in it have been
> instrumental in my development of this product.
> pure brilliance.
Glad to know, I could be of some help... Thanks for reading my blog and giving feedback.

@Corey: Did you find the solution for your problems? Unfortunately, you can not control things inside YouTube player because of crossdomain scripting... Why don't you create your own player to play YouTube videos? You would have more control?

Thanks

-abdul

Posted by: Abdul Qabiz at May 27, 2007 03:11 PM

Is there any truth to what Doon Rothmani is saying about this being a violation of some sort?

If I am correct, this code is being used for sites like Mixercast.com.

And how does Mixercast stream video from other sites like Brightcove Bip.tv is it with this same code?

Posted by: Dow at May 29, 2007 05:49 PM

@Dow:

> Is there any truth to what Doon Rothmani is saying
> about this being a violation of some sort?

I don't know about violation but we are surely doing things using workaround. YouTube! doesn't give you URL and we are doing working arounds..

In case of Doon Rothmani, he gamed the system to be among top videos, though I had never thought someone can use my script that way...

> If I am correct, this code is being used for
> sites like Mixercast.com.

Kind of..

> And how does Mixercast stream video from other
> sites like Brightcove Bip.tv is it with this
> same code?

Blip.tv gives you Media RSS (an API also), they also give the URL for flash-videos (flv), so it's easy. Brightcove doesn't give video-path, so it's tricky to use their videos, infact they have kind of tight DRM thingy in there...

-abdul

Posted by: Abdul Qabiz at May 29, 2007 06:39 PM

Hello Abdul, i've been given a task at my school to create video player same like yours with Adobe Flex that is using URL's from youtube to play videos. I have tried the sample video on the site, but then i tried to play another link (for video) from youtube.com and it wasnt working. I need the complete working source code, so i can use it for school, but i dont know if i have to copy the codes from the begining: Flex 2.0/ActionScript 3.0 example and ActionScript 2.0 code-snippet and use it in Adobe Flex Builder to create the player, because i'm a total Noob about this. How can i get the whole working (fixed) source code so i can present it at school? Thanks kindly in advance
PS: I have been surfing online for 2 days and your project is the only one i found that could really help me.

Posted by: Zoran at May 30, 2007 03:14 AM

@Zoran:

You need to enter the URL in this format:-

http://www.youtube.com/v/

Example:-

http://www.youtube.com//v/b2oegRiaA_0

That should work fine..

-abdul

Posted by: Abdul Qabiz at May 30, 2007 03:00 PM

Thanks Abdul, it worked fine and i tried couple of videos from youtube. Is there any tutorial how to create this in flex step by step,because i never used Adobe Flex Builder before. I need to create it, put it on cd and present it by Friday, so i don't have much time :(
Help from anyone will be appreciated.
Thanks again

Posted by: Zoran at May 31, 2007 04:56 AM

I have the url for the video, and it played in your player. Now where can I find a player or an embed script to fit the video into a different skin? Do I need a .flv player or a .php player?

Posted by: Will at May 31, 2007 11:52 AM

I am trying to embed the constructed .flv url into a flash script like this. Is this possible? Do I need a file extension at the end of the constructed url?

Any help would be much appreciated.

Posted by: Will at May 31, 2007 01:09 PM

I don't understand how to use the constructed .flv url. Is it possible to use this url to easily package the content into a different flash player, or is this solely a demonstration of how to get and view the video from the various parameters already given by Youtube?

I tried to insert the url into an embed flash script but I am clearly missing something.

This is a great demonstration btw, and any help would be appreciated.

Posted by: Will at May 31, 2007 02:03 PM

I've created this so far:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">

<mx:button label="Play" click="vp.play()" right="70" top="10"/>

<mx:button label="Stop" click="vp.stop()" right="10" top="10"/>

<mx:TextInput
id="inputURL"
text="http://server/file.flv" left="10" right="129" top="10"/>

<mx:VideoDisplay
id="vp"
autoPlay="true"
source="{ inputURL.text }" left="10" right="10" top="39" bottom="10"/>

</mx:Application>

and when i press run,it says i got errors in the code for building stop and play buttons:

<mx:button label="Play" click="vp.play()" right="70" top="10"/>

<mx:button label="Stop" click="vp.stop()" right="10" top="10"/>

Anyone help about how to add 2 buttons for playing and stopping the video?
Thanks
Zoran

Posted by: Zoran at June 1, 2007 12:55 AM

Error is the same for the two buttons, it says Could not resolve to a component implementation.

Posted by: Zoran at June 1, 2007 01:55 AM

Actually it wasn't that code, its this: (Sorry for the mistake)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">

<mx:button label="Play" click="vp.play ()"/>

<mx:button label="Stop" click="vp.stop ()"/>

<mx:TextInput
id="inputURL"
text="http://server/file.flv" left="10" right="129" top="10"/>

<mx:VideoDisplay
id="vp"
autoPlay="true"
source="{ inputURL.text }" left="10" right="10" top="39" bottom="10"/>

</mx:Application>

Posted by: Zoran at June 1, 2007 02:06 AM

@Zoran: Your code looks good, it's mx:Button not mx:button...

Hope that helps..

-abdul

Posted by: Abdul Qabiz at June 1, 2007 09:41 PM

Am i to understand that the "T" value changes regularly? or does it stay the same?

Cheers..

Posted by: Bitcloud at June 6, 2007 07:53 PM

For one video, it might different (I believe it has something to do with CDN stuff).

BTW! Check out another post of mine, where you don't need "t" param.

http://www.abdulqabiz.com/blog/archives/general/update_getting_youtu.php

Posted by: Abdul Qabiz at June 6, 2007 09:06 PM

Abdul,

Since when do students request "the complete source code" for a project? I though students were given projects to learn how to do things THEMSELVES. things must have changed dramatically since i got my comp sci. degree!

If I were you (which I am not, and I realize this) I would tell this type of poster to quite frankly bug off.

Any one who is a student and can't even debug a typo in his code does not deserve to have a project handed to him, much less graduate with a degree in computer technology. He will only grow to be a parasite producing nothing for himself and grabbing credit from others.

People who can't write (or debug) their own code or who are too lazy to do so, should be doing something else with their time.


just my humble opinion. sorry, but reading some of these posts really peed me off.

doon

Posted by: DoonRothmani at June 7, 2007 10:36 AM

Hey Abdul, sometime ago I asked whether this could be used to play videos from sites like Revver. But I checked out their API and was unsure of what to include.

Could you give me a further point in the right direction as to getting Revver to play like your youtube code.

Just wanting to take advantage of the higher quality videos from sites like Revver. Thanks!

Posted by: Dow at June 8, 2007 12:44 AM

Hi Abdul,

Could you give pointers to convert your as3 code to equivalent perl code?

Regards,
Neha

Posted by: zippeddinosaur at June 21, 2007 03:55 AM

It works fine in Flex, but not in flash CS3. The flvplayback component just doesn't buffer.. If someone has tried this and succeed, please write back (you can contact me at this adress : stef.schittly--laposte.net). You can find my source files here : http://lab.st-f.net/actionscript/flvPlayer/

Posted by: stéphane Schittly at June 23, 2007 09:22 PM

Hey Abdul, Thank You very much. Excellent work. It is very very helpful. I have been searching for this logic for quite some time. I am just not sure whether it is legal to do this. I am hoping yes it is, else google would have blocked such access long back.

Posted by: Arvind Tiwari at June 29, 2007 05:58 PM

@Arvind: Glad it helped you, I am not sure of legal aspect of this. As long as I understand, it's a workaround which seems to be used by different sites (brightcove, flektor, mixercast etc).

-abdul

Posted by: Abdul Qabiz at July 1, 2007 06:45 PM

change _mclListener.onLoadStart to _mclListener.onLoadInit

and it will work in IE

Posted by: francis at July 6, 2007 10:25 AM

This is great. But I wanted to plug in any URL without having to change it myself and plus the URL was hardwired into the function. I changed the function "startloading" code around so that you can just type/paste any of the Videos URL from YouTube and get instant gratification. I changed the function to this...

private function startLoading ():void {
var excludeLink:String = "http://www.youtube.com/watch?v=";
var lngExclude:Number = excludeLink.length;
var lngLength:Number = urlText.text.length;
var txtYouTubeLink:String = urlText.text.slice(lngExclude,lngLength);
var youTubeLink:String = "http://www.youtube.com/v/" + txtYouTubeLink;
var req:URLRequest = new URLRequest (youTubeLink);
loader.contentLoaderInfo.addEventListener(Event.INIT, handlerLoaderInit);
loader.load(req);
logMessage ("Loading YouTube URL..");
}

Posted by: RconR007 at July 19, 2007 01:07 AM

First off ,
Good example here, works great on its own, however when you do use this inside of any other part of the app these type errors occur,
**
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at /private::startLoading()
at /__submitButton_click()
at [mouseEvent]


Runtime error is at

loader.contentLoaderInfo.addEventListener(Event.INIT, handlerLoaderInit);

**

This is using flex 3,

Cheers

Drop me a link if you get this one figured out.....

Posted by: Michael at July 27, 2007 01:13 PM

Hi,
I'm trying to include and play youTube video from with a swf I have prepared but I don't know how to do it. I've read the code but I'm not an expert and I don't really understand it. Sorry.
I have this information: the target movieChild within the swf is "videoBox" and I want to repace it with the video from youTube so the video is exactly the right size and position.Can this be done? the URL of the video is: "http://www.youtube.com/watch?v=hs94ojVu7t"

Posted by: Dorian at August 1, 2007 07:54 PM

I got it to work with both AS2 and AS3 Flex

However I need to load a video inside an AS2 project i made, but the youtube player appears inside my as2 project, where in flex ONLY the video appears.

How would I do this in AS2 ?

Posted by: Allen at August 2, 2007 12:34 PM

@Dorian: You can learn how to play a FLV in Flash then you can just replace the FLV url with the YouTube FLV URL which you can construct using different techniques (some mentioned on my blog).

@Allen: I really didn't get what problem you are facing? Can you please write it again, may be in technical words or with some code you are trying to use?

Thanks

-abdul

Posted by: Abdul Qabiz at August 3, 2007 02:04 PM

Hi Abdul,

Ok let me re-phrase. When I put together the example using AS3 in Flex, it worked perfect, and only the actual video shows.

But when I tried the AS2 example inside my AS2 project, the YouTube video player appears, just like on the youtube website, with the red srubber bar and the whole youtube video player interface. Thats the problem.

I hope i explained better this time, and maybe you can point in me the right direction on how to "remove" the youtube player interface from my AS3 project.

Thanks Abdul!

Posted by: allen at August 5, 2007 08:26 AM

Hey there,

Has anyone managed to recreate the play/stop button within flash?

Posted by: benjamin at August 10, 2007 01:34 PM

Guys,

I have been on vacation hence I couldn't respond to your comments. I would do it very soon, one by one, I would try to answer all queries.

Thanks

-abdul

Posted by: Abdul Qabiz at August 12, 2007 12:17 AM

Hi everyone,

i'm sure somes of you will be please to find the equivalent of da ActionScript method in PHP5 ;-)
I give you my sourcecode tested with success :-)

don't forget sharing and diversity and everything get your favorites videos with joy ;-)

greetings from france

/*
* @ edited by Nicoweb 2007
* 12/08/2007 19:13pm
* youtube-url-source-00.php
*/
ini_set("max_execution_time","3600");
$baseUrl = "http://www.youtube.com/v/%s";
$idVideo = "3IcwG0jUFxU";
$urlVideo = sprintf($baseUrl,$idVideo);
$baseVideoUrl = "http://www.youtube.com/get_video.php?%s";

ob_start();
// get via CuRL da great library so fine ;-)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlVideo);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
$out = ob_get_clean();

$strs = explode("&t=",$out);
$final = explode("\n",$strs[1]);
$t = $final[0];
$finalUrlVideo = getVideoUrl($idVideo,$t);

$filv = file_get_contents($finalUrlVideo);
$fo = fopen("file.flv","w+");
$fw = fwrite($fo,$filv);
$fc = fclose($fo);

/* getVideoUrl ( string idVideo , string tValue ) */
function getVideoUrl ($id,$tval) {
global $baseVideoUrl;
return sprintf($baseVideoUrl,"video_id=".$id."&t=".trim($tval));

}

Posted by: Nicoweb, Mr Bertelle Nicolas at August 13, 2007 01:39 AM

@benjamin: That's done and thats what you can achieve if you look at the examples on this blog or web... Using different techniques allows you to load, stop, play, rewind etc YouTube videos....

@Nicoweb: That looks neat, thanks for it..

-abdul

Posted by: Abdul Qabiz at August 20, 2007 11:27 PM

thanks dude....


i've been looking for this. its sad that such a popular service like youtube has an api that is surrounded by so many hacks... i think they should open up the api a bit more.

p34c3

Posted by: ryan at August 28, 2007 05:46 PM

Hi everyone,
I've made a player using FLVPlayback component from Flash 8.0 and I don't understand why it does work on Firefox and it doesn't on IE6 and IE7. Could anyone help me? Thanks a lot...
Iulian

Posted by: Iulian at August 31, 2007 01:27 PM

I must be missing something really obvious. A few folks have mentioned this already, but I haven't seen a concrete answer.

Using the AS2 code works just fine for downloading the flv, but not when you try and send it to the FLVPlayback using the contentpath.

I used:
FLVPlayback.contentPath = constructFLVURL (_lv.video_id, _lv.t);
which produces a 1005 Error claiming it must have the .flv extension.

Can anyone shed some light on this for me?

Posted by: Evian at September 5, 2007 09:52 PM

I must be missing something obvious here. When using the AS2 version it works fine, but when I use the constructFLVURL function for the contentPath,I get the 1005: Error which states that I need the .flv extension. Am I the only one with this error? Copying that same string into a browser prompts me to download so I know it isn't the string. Thanks for any help, this will absolutely revolutionize my current project!

Posted by: Evian at September 5, 2007 10:35 PM

Hi,

Can I have the source for your YouTubeClientSideDemoFlex.swf file?

Posted by: Hendra at September 7, 2007 01:43 PM

@Evian: FLVPlayback checks for flv extension, there is some issue with it. I would check for a workaround...It's weird that FLVPlayback missed a use-case like this, in web-application we do use redirects and not always depends on file-extension...

@Hendra:- The first code snippet in above post is the source-code of YouTubeClientSideDemoFlex.swf...

-abdul

Posted by: Abdul Qabiz at September 7, 2007 10:56 PM

Is the php script on Youtube's side no longer working? It's returning a 410 Gone code, which tells me that it's a permanent move on their part.

Which, sorta brings us back to square one. How are the players deriving the subdomain that the .flv is coming from?

Posted by: Jeffery at September 10, 2007 02:03 PM

@Jeffery: I just checked it works, it might not be working for some video_ids?

-abdul

Posted by: Abdul Qabiz at September 10, 2007 05:00 PM

Thanks for wonderful into. I do have a question. I have been using video player that uses, component FLVPlayBack that came with Flash8. How do I supply the youtube path to this component? It asks for contentPath which should be a flv file. Any suggestions would be great. Thanks again.

Posted by: Rabi at September 11, 2007 12:44 PM

Ah. I see the issue.

Youtube changed the FlashVar format to a string keyed object. It used to be provided via the url query string.

var swfArgs = {hl:'en',video_id:'IZfIFzBsDsU',l:'69',t:'OEgsToPDskIIJps_QOHBWRlp-jl8Z66t',sk:'2OO-1MpUsGx0EJkFDrt7SQU'};

Apologies for the formatting.

So, I'm using a PHP regular expression to snag it:
preg_match('/var swfArgs = {hl:\'([^\']+)\',video_id:\'([^\']+)\',l:\'([^\']+)\',t:\'([^\']+)\',sk:\'([^\']+)\'};/', $page, $regs);
$pass_to_getvideo = $regs[2]."&hl=".$regs[1]."&l=".$regs[3]."&t=".$regs[4]."&sk=".$regs[5];

Posted by: Jeffery at September 14, 2007 02:01 AM

Use http://cache.googlevideo.com/get_video?video_id=ffMSy8usAlc&.flv

where "ffMSy8usAlc" is the youtube id
Works with FLVPlayback component in Flash 8.

Posted by: Rabi at September 14, 2007 07:33 AM

Has anyone else gotten what Rabi suggested to work?

I still get a 1005 Error.



"1005: Invalid xml: URL: "http://cache.googlevideo.com/get_video?video_id=JHUuqsSCn5g&.flv&FLVPlaybackVersion=1.0.1" No root node found; if url is for an flv it must have .flv extension and take no parameters"



What is really weird is it auto adds "&FLVPlaybackVersion=1.0.1" to my URL, I didn't add that.



Let me know if anyone has found a work around for the FLVPlayback component in Flash 8.

evian.

Posted by: Evian at September 25, 2007 03:04 AM

Hi everyone,

next to a work on youtube, i saw that Google add a new type of API that make the old one deprecated.
It may explain the problem encoutered by one of you in the comments below.

Enjoy sharing and looking videos on youtube ;-)

Posted by: Bertelle Nicolas at October 4, 2007 09:32 PM

@Nicoweb: You made me lazy, anyway Thanks :)

Posted by: shanX at October 6, 2007 01:10 AM

Im trying to figure out how to get my videos to autoplay on You tube... for example...I know the code &autoplay=1

But it does work on Myspace but it doesnt work on Youtube....I want my video to play when someone views my Channel....Please help....

Posted by: Calvin at October 9, 2007 01:21 AM

Hi,
i am ram prasath.i am created an flash file to play youtube videos using action script 3.

The following error was return in my console


VideoError: 1005: Invalid xml: URL: "http://www.youtube.com/get_video.php?video_id=3IcwG0jUFxU&t=OEgsToPDskK-JSXCoECKg-4KUiDLgOps&FLVPlaybackVersion=2.0" No root node found; if url is for an flv it must have .flv extension and take no parameters
at fl.video::SMILManager/http://www.adobe.com/2007/flash/flvplayback/internal::xmlLoadEventHandler()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

i mentioned the full flash script below

Plz provide some solution for me.I am trying this flash to play in local network not even in html file.

import flash.events.Event;

import fl.events.ComponentEvent;

import fl.events.ColorPickerEvent;

import fl.controls.RadioButtonGroup;

import fl.containers.UILoader;

import flash.net.NetConnection;

import flash.net.NetStream;

import fl.video.*;

import flash.net.*;

mport flash.display.*;

var loader:Loader;

var rbGrp:RadioButtonGroup = RadioButtonGroup.getGroup("fontRbGrp");

rbGrp.addEventListener(MouseEvent.CLICK, rbHandler);

txtCp.addEventListener(ColorPickerEvent.CHANGE,cpHandler);

msgCb.addEventListener(Event.CHANGE, cbHandler);

var tf:TextFormat = new TextFormat();

onAppCreationComplete();

function rbHandler(event:MouseEvent):

void { switch(event.target.selection.name) { case "smallRb": tf.size = 14; break; case "largerRb": tf.size = 18; break; case "largestRb": tf.size = 24; break; } trace(event.target.selection.name);

aTa.setStyle("textFormat", tf); }

function cpHandler(event:ColorPickerEvent):void

{ tf.color = event.target.selectedColor; aTa.setStyle("textFormat", tf); }

function cbHandler(event:Event):void { aTa.text = event.target.selectedItem.label; }

function onAppCreationComplete ():void { trace("Executed on load");

loader = new Loader ();

var req:URLRequest = new URLRequest ("http://www.youtube.com/v/3IcwG0jUFxU");

loader.contentLoaderInfo.addEventListener(Event.INIT, handlerLoaderInit);

loader.load(req);

logMessage ("Loading YouTube URL.."); }

function logMessage (message:String):void

{ //outputText.text += message + "\n"; trace (message); }

function handlerLoaderInit (event:Event):void

{ logMessage ("Loaded, processing: " + loader.contentLoaderInfo.url);

var urlVars:URLVariables = new URLVariables ();

urlVars.decode (loader.contentLoaderInfo.url.split("?")[1]);

logMessage ("Processed:-"); logMessage ("\t\t video_id:" + urlVars.video_id);

logMessage ("\t\t t param:" + urlVars.t); logMessage ("\t\t thumbnail-url:" + urlVars.iurl);

var flvURL:String = constructFLVURL(urlVars.video_id, urlVars.t);

logMessage ("YouTube FLV URL: " + flvURL);

var my_FLVPlybk = new FLVPlayback();

my_FLVPlybk.x = 79; my_FLVPlybk.y = 130; my_FLVPlybk.bufferTime = 0.1;

addChild(my_FLVPlybk);

my_FLVPlybk.skin = "file:///c|/Program Files/Adobe/Adobe Flash CS3/en/Configuration/FLVPlayback Skins/ActionScript 3.0/SkinOverPlaySeekMute.swf"; my_FLVPlybk.source = flvURL;

my_FLVPlybk.play(); logMessage ("Started Playing Video...");

loader.unload();

}

function constructFLVURL (video_id:String, t:String):String {

var str:String = "http://www.youtube.com/get_video.php?"; str += "video_id=" + video_id; str += "&t=" + t; return str; }


Posted by: Ram Prasath at October 10, 2007 07:43 PM

Dear Abdul,
I am creating Video Player using SWFLoader in Flex. I want to load the different videos on clicking of each button. For any first click of button it starts playing video from youtube or google video but as soon as i click on other button for different video it goes in the loading mode and i am not able to see the video. Alos on local my swfLoader size is correct but as soon as i upload on the we server it height and width becomes very large. See my Code below-


creationComplete="init()">

import mx.rpc.events.AbstractEvent;
import mx.containers.VBox;
import mx.controls.*;
import mx.effects.*;
import mx.events.EffectEvent;

private var currVid:DisplayObject;

private function init():void{
var b:Button=new Button();
b.label="hello";
// b.addEventListener(MouseEvent.CLICK,Alert.show("Hello"));
canVideo.addChild(b);
}
private function addVideos():void{
canVideo.addChild(currVid);
}

private function showVid(url:String):void{
canVideo.removeAllChildren();
var loader:SWFLoader = new SWFLoader();
loader.load(url);
loader.name = "loader";
//loader.scaleContent = false;
//loader.maintainAspectRatio = true;
loader.width = 150;
loader.height = 150;
loader.addEventListener(Event.COMPLETE, onImageLoaded);

canVideo.addChild(loader);
canVideo.clipContent=false;

}
private function onImageLoaded():void{
Alert.show("Loaded");
}
]]>







Posted by: Pritam at October 29, 2007 04:10 PM

@Pritam

I am experiencing similar problems in as2.

I can load one video into a player, but subsequent videos constantly buffer, and never load. I'm stumped as to why this could be.

I suspect your problem with resizing is one I have already over come. In AS2 I set an onLoadInit handler to resize once the movie is loaded. I'm not familiar with flex, but I imagine you could put the resize in the onImageLoaded listener instead.


Posted by: Ben at November 3, 2007 05:04 AM

I don't see how the AS2 code posted above could possibly work. The URL is:

http://www.youtube.com/v/3IcwG0jUFxU

The code relies on the fact that the following line splits the url into its various pieces:

_lv.decode (target._url.split ("?")[1]);

However, there is no '?' in the url, so the above code will return undefined. All subsequent properties will return undefined as a result.

Posted by: clayton at November 23, 2007 01:14 AM

@Clayton

when the given link;

it is redirected to the link as mentioned below;
http://www.youtube.com/swf/l.swf?video_id=3IcwG0jUFxU&eurl=&iurl=http%3A//img.youtube.com/vi/3IcwG0jUFxU/default.jpg&t=OEgsToPDskK8DWRmRDamYAyrq0qe43vu&rel=1&border=0

which of course, consists '?' ;

this procedure is basically done to get the 't' value from the link which in this case is

I hope now its clear to you;

Thanks to Abdul for this brilliant crack;

Regards

Posted by: Arun Lal at November 29, 2007 09:58 AM

Hello guys,

The FLVPlayback-component isn't able to play the parsed files within flash 9.
I'm searching for a workaround for 2 days now and I'm really helpless...

How can I force the FLVPlayback to load such a file:
http://gdata.youtube.com/feeds/api/videos/Zo52T7uKOJU/related

Regards

Posted by: dEPUTsTERONE at December 27, 2007 09:19 PM

You can use MediaDisplay (or MediaPlayback) component to avoid "VideoError: 1005".

Posted by: zulin at January 4, 2008 06:14 PM

I dont know how to do it can someone mail it to me with this video OS3eBdJczn8

Posted by: Lijo at January 12, 2008 06:52 PM

Thanks for this awesome work.

One question I have is -- once we've constructed an FLV url, I notice that YouTube returns something different, each time the script is run.

However, the previous url works, at least a few seconds later.

Do the FLV urls stop working? i.e. do we need to call it again, for the same video, every time we want to use it? or can we save the constructed flv url and reuse it each time we want the youtube video?

Posted by: Susan at January 14, 2008 05:54 AM

@Susan:-

> YouTube returns something different
>, each time the script is run.

Yup! It returns the closes or available server

> Do the FLV urls stop working?
Not sure of that..

> Do the FLV urls stop working?
> i.e. do we need to call it
> again, for the same video,
> every time we want to use it?
> or can we save the constructed
> flv url and reuse it each time
> we want the youtube video?

You can do either of these. Call the code everytime to get the URL or save the URL (returned) and used it later... Latter one might be faster, if your users are in same geography (like USA or Europe etc). If you have users from all over the world, you might want to use former approach (get URL everytime)..


BTW! Did you check out my other posts of YouTube FLV path using server-side tricks?

-abdul

Posted by: Abdul Qabiz at January 14, 2008 05:42 PM

the easiest way is to call this webservice http://youtubexml.com/?url=http://www.youtube.com/watch?v=irp8CNj9qBI

Posted by: sam at January 15, 2008 09:54 PM

Hi Abdul, I am able to construct video url but I am unable to find a way to play a video on cross-domain context.

Posted by: Rohit at January 19, 2008 12:22 PM

@Rohit: FLV should play and there is no crossdomain.xml required for playing flv files, it might be required when you want to capture the bitmap...

Check this out:-

1) Go to http://www.abdulqabiz.com/temp/flvPlayer.swf
2) Paste this url: http://youtube.com/get_video?video_id=gttvfPjLV1I&t=OEgsToPDskLQpM1nn8G0f6lVIRXvmeag


It works fine..

-abdul

Posted by: Abdul Qabiz at January 19, 2008 01:02 PM

Hey Abdul,
I am trying to use your AS2 code as part of my player. I keep getting the security sandbox violation, though.



I tried adding System.security.allowDomain ("youtube.com") at the beginning of the actionscript code but it still pops up. Also, would you know what/where I'd put the code to autoplay?



Here's my code. I've only started learning actionscript since I started streaming videos so I do not know too much. Perhaps you have any suggestions to make it more efficient, too? I'm just chopping up codes until it works :P



System.security.allowDomain ("youtube.com")

createEmptyMovieClip ("mc", getNextHighestDepth ());

var _mcl:MovieClipLoader = new MovieClipLoader ();

_mcl.addListener (_mclListener);

_mcl.loadClip ("http://www.youtube.com/v/oqNMx_1jmlU", mc);

_mclListener = new Object ();

_mclListener.onLoadStart = function (target:MovieClip)

{

var _lv:LoadVars = new LoadVars ();

_lv.decode (target._url.split ("?")[1]);

_mcl.unloadClip (target);



var connection_nc:NetConnection = new NetConnection();

connection_nc.connect(null);

var stream_ns:NetStream = new NetStream(connection_nc);

my_video.attachVideo(stream_ns);

stream_ns.play("http://www.youtube.com/get_video.php?video_id=" + _lv.video_id + "&t=" + _lv.t);

stream_ns.setBufferTime(15);

};

Posted by: Washiki at January 21, 2008 01:21 AM

Thank you very much... This is very useful.

Posted by: crucifix at February 6, 2008 12:02 AM

vorrei mettere dei video su yutube

Posted by: lorena at February 13, 2008 10:22 PM

>Flash clients would require server-side proxy

Abdul,
But your example code in Flex AS3 seems to go to YouTube directly! How does this work?

Posted by: Andy at February 13, 2008 11:02 PM

Don't know for sure how off-topic this is, but if you get into some errors, like 100;

try to handle your php/asp flv source in flash like:
your-folder/whatever/stream.php/anything-here.flv

Posted by: Robin Casey at February 15, 2008 04:02 AM

@Andy: My example in AS3 is not using YouTube RSS feed or API. Both of those operations are crossdomain data loaoding operations and require either a liberal crossdomain.xml on youtube.com or proxy on your server...

What I am doing above is a hack to get the "t" param and then construct flv url from that. I am not sure, this hack still works, I need to spend sometime updating all my posts/code related to youtube.

@Robin: Never encountered that error, but thanks for the update.

-abdul

Posted by: Abdul Qabiz at February 15, 2008 08:34 PM

Abdul, thanks for your reply. I actually didn't realize that when the docs said "Flash can't load data from another domain without the crossdomain.xml file" that did not include things like reading the FLV file. Thanks for clearing that up.

I've been trying to get the FLVPlayback control that comes with Flash to use the youtube URL, but for whatever reason it doesn't seem to work. Does it expect an url with a FLV extension or something? Any idea?

Thanks.
Great blog. Very helpful.
-Andy

Posted by: Andy at February 15, 2008 09:55 PM

@Andy: FLVPlayback has hardcoded logic for file-extension, it looks for .flv in the end. I have seen people finding out workaround for that..Please read above comments or search, I am sure it has been solved..

Did you try appending &.flv in the end of URL, see if it works?

-abdul

Posted by: Abdul Qabiz at February 15, 2008 10:11 PM

Nice cript, but do you know how to make a video preload?

thanks

Posted by: Danny at February 25, 2008 06:23 PM

can you make the YouTubeClientSideDemoFlex.fla available? I'm a newbie

Posted by: Pete at February 28, 2008 03:48 AM

@Pete: There is no .fla file for that code, it's a flex app, and code is there in my post above (the first code box)...

Sorry, you have to wait and post the comment again..
-abdul

Posted by: Abdul Qabiz at February 28, 2008 11:08 PM

Hey Abdul,

I've having some issues with AS3 (not Flex) and loading .flv from youtube using your technique.

I can get your technique to work for grabbing the URL but when I tried to play it in the FLVPlayback component I get a security sandbox violation as below:

*** Security Sandbox Violation ***
Connection to http://www.youtube.com/get_video.php?video_id=eBGIQ7ZuuiU&t=OEgsToPDskIQtQo0D-3opVzh3CDEzbwl&FLVPlaybackVersion=2.0 halted - not permitted from http://www.gemtowerdefense.com/test.swf

Now, your example http://www.abdulqabiz.com/temp/flvPlayer.swf works for the URLs I grab, is that example a Flex app or an AS2 app or an AS3 app?

Posted by: Peter at March 11, 2008 01:57 AM

@Peter: That's a flex app, I would investigate why it's not working for you.

Thanks for feedback.

-abdul

Posted by: Abdul Qabiz at March 11, 2008 02:58 AM

This code works just fine. Can I ask how do you now send this video as an email?

Thanks,
Mike

Posted by: mike at March 18, 2008 10:51 AM

Hi Abdul, I've made everythig, I understand that the as2 is for retrieving the flv file but it only works for a download as any other online tools. I tried the app en Flex and obviously works fine too, but how can I play the flv in flash? I'm driving crazy trying to I know how to do that with a static flv address, but I really don't find the way to make it using the string URL. tks.

Posted by: Jacob at March 26, 2008 04:21 AM

thank you for that hint!

the link to the .flv is all i need.

Posted by: jake at April 14, 2008 02:30 AM

I didn't use your script code, but it's similar and when I unload a YouTube video and then then load a different one, the one that was playing before it loads and plays instead of the new one. what could be the problem? and may I ask for the actual FLA file for your example if it isn't too much of a trouble?? thanks.

Posted by: sx at April 22, 2008 03:09 AM

Thanks for posting this.

Can you please update the original AS2 code so that is uses onLoadInit rather than onLoadStart?

onLoadStart does not work in IE.

That will save others a lot of time troubleshooting and will make this page more popular.

Thanks

Posted by: adam bowman at April 30, 2008 08:02 AM

I'm a complete noob so forgive me for asking this.
I'd like to able to play this video: http://youtube.com/watch?v=gYo2XlgL8pQ

When I enter the altered url http://youtube.com/v/gYo2XlgL8pQ in the test application the video is played.

I however don't understand how I can get this to work on my site, what do I need to put in my html ?

any help is greatly appreciated

Posted by: nick at April 30, 2008 06:19 PM

This is the class which I created using Flash CS3 (Action script 3.0)using Abdul's techniques for playing youtube video . I am posting it coz it might be useful for somebody . it plays hard a movie from this url "http://www.youtube.com/watch?v=KmrdWpXSnoo&feature=related" which is hard coded

package{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.net.*;
import flash.media.Video;
import flash.events.*;
import flash.display.Loader;
import flash.system.*;

public class VideoTest extends Sprite
{
private var vidLoader:Loader;
private var flvURL:String;
private var videoID:String;
private var vidRequest:URLRequest;
public function VideoTest()
{
flash.system.Security.allowDomain("http://www.youtube.com");
flash.system.Security.loadPolicyFile("http://www.youtube.com/crossdomain.xml");
var vidURL:String = normalizeURL("http://www.youtube.com/watch?v=KmrdWpXSnoo&feature=related");
var vidRequest:URLRequest = new URLRequest(vidURL);
vidLoader = new Loader();
vidLoader.contentLoaderInfo.addEventListener(Event.INIT, onVidRequestLoad);
vidLoader.load(vidRequest);

}
private function onVidRequestLoad(evt:Event):void
{
trace("in onVidRequestLoad");
var vars:URLVariables = new URLVariables();
vars.decode(vidLoader.contentLoaderInfo.url.split("?")[1]);
videoID = vars.video_id;
flvURL = constructFLVURL(vars.video_id, vars.t);
trace(flvURL);
trace("out onVidRequestLoad");
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play(flvURL);
function asyncErrorHandler(event:AsyncErrorEvent):void
{
trace("error");
}
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
}
private function constructFLVURL(video_id:String, t:String):String
{
var tmp:String = "http://www.youtube.com/get_video.php?";
tmp += "video_id="+video_id;
tmp += "&t="+t;
return tmp;
}
private function normalizeURL(URL:String):String
{
var tmp:String = URL;
tmp = tmp.split("watch?v=").join("v/");
return tmp;
}

}
}

Posted by: Anthony at May 7, 2008 04:19 PM

Post a comment




Remember Me?


Please enter the security code you see here

(you may use HTML tags for style)