Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="application1_creationCompleteHandler(event)">
- <fx:Script>
- <![CDATA[
- import mx.core.UIComponent;
- import mx.events.FlexEvent;
- // The player SWF file on www.youtube.com needs to communicate with your host
- // SWF file. Your code must call Security.allowDomain() to allow this
- // communication.
- // This will hold the API player instance once it is initialized.
- var player:Object;
- var timer:Timer;
- var loader:Loader = new Loader();
- function onLoaderInit(event:Event):void {
- var container:UIComponent = new UIComponent();
- addElement( container );
- container.addChild( loader );
- loader.content.addEventListener("onReady", onPlayerReady);
- loader.content.addEventListener("onError", onPlayerError);
- loader.content.addEventListener("onStateChange", onPlayerStateChange);
- loader.content.addEventListener("onPlaybackQualityChange",
- onVideoPlaybackQualityChange);
- }
- function onPlayerReady(event:Event):void {
- // Event.data contains the event parameter, which is the Player API ID
- trace("player ready:", Object(event).data);
- // Once this event has been dispatched by the player, we can use
- // cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
- // to load a particular YouTube video.
- player = loader.content;
- // Set appropriate player dimensions for your application
- player.setSize(480, 360);
- player.loadVideoById("KC283NYaddc");
- }
- function onPlayerError(event:Event):void {
- // Event.data contains the event parameter, which is the error code
- trace("player error:", Object(event).data);
- }
- function onPlayerStateChange(event:Event):void {
- // Event.data contains the event parameter, which is the new player state
- trace("player state:", Object(event).data);
- }
- function onVideoPlaybackQualityChange(event:Event):void {
- // Event.data contains the event parameter, which is the new video quality
- trace("video quality:", Object(event).data);
- }
- protected function application1_creationCompleteHandler(event:FlexEvent):void
- {
- loader = new Loader();
- loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
- loader.load(new URLRequest("https://www.youtube.com/apiplayer?version=3"));
- }
- ]]>
- </fx:Script>
- <fx:Declarations>
- <!-- Place non-visual elements (e.g., services, value objects) here -->
- </fx:Declarations>
- <s:HSlider x="84" y="10"/>
- <s:Button x="10" y="10" width="40" height="40" label="||>"/>
- </s:WindowedApplication>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement