Flex Generation Weblog

Archive for the ‘utubeasrc’ Category

<?xml version=”1.0″ encoding=”utf-8″?>

<!– You Tube Player in Flex –>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
width=”100%” height=”100%” layout=”vertical”>
<mx:Script>
<![CDATA[
private var youtubevideolink:String = ‘http://youtube.com/watch/v/CE9yKXSBARU&#8217;

private var youtubeloader:Loader = new Loader;

private function init(youTubeVideoLink:Object):void
{
var req:URLRequest = new URLRequest (String(youTubeVideoLink));
youtubeloader.contentLoaderInfo.addEventListener(Event.INIT, handlerLoaderInit);
youtubeloader.load(req);
}
// Function to play yOU TUBE VIDEO
private function handlerLoaderInit (event:Event):void
{
var urlVars:URLVariables = new URLVariables ();
urlVars.decode (youtubeloader.contentLoaderInfo.url.split(“?”)[1]);
var flvURL:String = constructYouTubeFLVURL (urlVars.video_id, urlVars.t);
utubeplayer.source =flvURL;
utubeplayer.play();

}
// Function for constructing youtube video url
private function constructYouTubeFLVURL (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 FullScreenVideo():void
{
utubeplayer.stage.displayState = StageDisplayState.FULL_SCREEN;
}
]]>
</mx:Script>

<mx:Button label=”FullScreen” click=”FullScreenVideo()” />

<mx:VideoDisplay width=”100%” height=”100%” id=”utubeplayer” initialize=”init(youtubevideolink)” />

</mx:Application>


June 2017
M T W T F S S
« Nov    
 1234
567891011
12131415161718
19202122232425
2627282930