Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
  3.                        xmlns:s="library://ns.adobe.com/flex/spark"
  4.                        xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="application1_creationCompleteHandler(event)">
  5.     <fx:Script>
  6.         <![CDATA[
  7.             import mx.core.UIComponent;
  8.             import mx.events.FlexEvent;
  9.             // The player SWF file on www.youtube.com needs to communicate with your host
  10.             // SWF file. Your code must call Security.allowDomain() to allow this
  11.             // communication.
  12.            
  13.             // This will hold the API player instance once it is initialized.
  14.             var player:Object;
  15.             var timer:Timer;
  16.             var loader:Loader = new Loader();
  17.            
  18.             function onLoaderInit(event:Event):void {
  19.                 var container:UIComponent = new UIComponent();
  20.                 addElement( container );
  21.                 container.addChild( loader );
  22.                
  23.                 loader.content.addEventListener("onReady", onPlayerReady);
  24.                 loader.content.addEventListener("onError", onPlayerError);
  25.                 loader.content.addEventListener("onStateChange", onPlayerStateChange);
  26.                 loader.content.addEventListener("onPlaybackQualityChange",
  27.                     onVideoPlaybackQualityChange);
  28.             }
  29.            
  30.             function onPlayerReady(event:Event):void {
  31.                 // Event.data contains the event parameter, which is the Player API ID
  32.                 trace("player ready:", Object(event).data);
  33.                
  34.                 // Once this event has been dispatched by the player, we can use
  35.                 // cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
  36.                 // to load a particular YouTube video.
  37.                 player = loader.content;
  38.                 // Set appropriate player dimensions for your application
  39.                 player.setSize(480, 360);
  40.                 player.loadVideoById("KC283NYaddc");
  41.             }
  42.            
  43.             function onPlayerError(event:Event):void {
  44.                 // Event.data contains the event parameter, which is the error code
  45.                 trace("player error:", Object(event).data);
  46.             }
  47.            
  48.             function onPlayerStateChange(event:Event):void {
  49.                 // Event.data contains the event parameter, which is the new player state
  50.                 trace("player state:", Object(event).data);
  51.             }
  52.            
  53.             function onVideoPlaybackQualityChange(event:Event):void {
  54.                 // Event.data contains the event parameter, which is the new video quality
  55.                 trace("video quality:", Object(event).data);
  56.             }
  57.            
  58.             protected function application1_creationCompleteHandler(event:FlexEvent):void
  59.             {
  60.                 loader = new Loader();
  61.                 loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
  62.                 loader.load(new URLRequest("https://www.youtube.com/apiplayer?version=3"));
  63.             }
  64.            
  65.         ]]>
  66.     </fx:Script>
  67.     <fx:Declarations>
  68.         <!-- Place non-visual elements (e.g., services, value objects) here -->
  69.     </fx:Declarations>
  70.     <s:HSlider x="84" y="10"/>
  71.     <s:Button x="10" y="10" width="40" height="40" label="||&gt;"/>
  72. </s:WindowedApplication>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement