YouTubePlayer API (2)
YouTubePlayer API (2)
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/3ypy
*/
////////////////////////////////////////////////////////////////////////////////
// YouTubePlayer API (2)
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.Loader;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.Security;
[SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]
public class Main extends Sprite {
private var player:Object;
private var loader:Loader;
//private static var youtubePath:String = "http://www.youtube.com/cp/UGP_hoQpLZQ?version=3&enablejsapi=1";
private static var youtubePath:String = "http://www.youtube.com/v/UGP_hoQpLZQ?version=3&enablejsapi=1";
private static var playerWidth:uint = 448;
public function Main() {
//Wonderfl.capture_delay(1);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
init();
}
private function init():void {
Security.allowDomain("www.youtube.com");
Security.allowDomain("s.ytimg.com");
//Security.loadPolicyFile("http://www.youtube.com/crossdomain.xml");
//Security.loadPolicyFile("http://s.ytimg.com/crossdomain.xml");
loader = new Loader();
addChild(loader);
loader.x = uint((465 - playerWidth)/2);
loader.y = uint((465 - playerWidth/16*9 - 32)/2);
loader.contentLoaderInfo.addEventListener(Event.INIT, initialize, false, 0, true);
loader.load(new URLRequest(youtubePath));
}
private function initialize(evt:Event):void {
loader.content.addEventListener("onReady", ready, false, 0, true);
}
private function ready(evt:Event):void {
player = loader.content;
player.setSize(playerWidth, playerWidth/16*9+32);
//player.cueVideoById("ZL5d6vPEhMw", 0, "small");
}
}
}