YouTube AS3 Player API

by nipx
YouTube APIを試します。
♥2 | Line 72 | Modified 2010-05-01 22:56:47 | MIT License
play

ActionScript3 source code

/**
 * Copyright nipx ( http://wonderfl.net/user/nipx )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jlLH
 */

package {
	
	
	import jp.progression.casts.*;
	import jp.progression.commands.*;
	import jp.progression.commands.display.*;
	import jp.progression.commands.lists.*;
	import jp.progression.commands.managers.*;
	import jp.progression.commands.media.*;
	import jp.progression.commands.net.*;
	import jp.progression.commands.tweens.*;
	import jp.progression.config.*;
	import jp.progression.data.*;
	import jp.progression.debug.*;
	import jp.progression.events.*;
	import jp.progression.executors.*;
	import jp.progression.loader.*;
	import jp.progression.scenes.*;
	
	[SWF(width="400", height="400", frameRate="30", backgroundColor="#000000")]
	
	
	/**
	 * YouTube APIを試します。
	 */	
    public class FlashTest extends CastDocument {
        
        public function FlashTest() {
	        	super( "index", IndexScene, new BasicAppConfig() );
        }
		
		override protected function atReady():void {
			manager.goto( manager.root.sceneId );
		}
		
    }
}

import jp.progression.casts.*;
import jp.progression.commands.*;
import jp.progression.commands.display.*;
import jp.progression.commands.lists.*;
import jp.progression.commands.managers.*;
import jp.progression.commands.media.*;
import jp.progression.commands.net.*;
import jp.progression.commands.tweens.*;
import jp.progression.config.*;
import jp.progression.data.*;
import jp.progression.debug.*;
import jp.progression.events.*;
import jp.progression.executors.*;
import jp.progression.loader.*;
import jp.progression.scenes.*;

import flash.display.*;
import flash.net.URLRequest;
import flash.events.*;



class IndexScene extends SceneObject {
	
	public function IndexScene() {
		_loader = new Loader();
	}
	
	
	
	private var _loader:Loader;
	private var _player:Object;
	
	
	
	protected override function atSceneLoad():void {
		
		
		addCommand(
			//Load系コマンドでうまく取得できませんでした。
			//策があったらFORKお願いします。
		    new Func( function():void{
		    	
		    		//embedded playerをロード http://www.youtube.com/v/{ VIDEO_IDを渡す }
		    		_loader.contentLoaderInfo.addEventListener( Event.INIT, onInit );
				_loader.load( new URLRequest( "http://www.youtube.com/v/ojqWclLQOxk?version=3" ) );
				
				//PLAYER格納
				function onInit( e:Event ):void{
					_player	= _loader.content as Object;
					_player.addEventListener( "onReady", onReady );
				}
				
				//PLAYER準備完了
				function onReady( e:Event ):void{
					_loader.alpha = 0;
					_loader.x = CastDocument.center - 160;
					_loader.y = CastDocument.middle - 120;
					_player["setSize"]( 320,240 );
					//コマンド完了
					_loader.dispatchEvent( new Event( Event.COMPLETE ) );
				}
		    			    		
		    }, null, _loader, Event.COMPLETE ),
		    new AddChild( container, _loader ),
		    new DoTweener( _loader, { alpha:1, transition:"easeNone", time:2 } )
		);
		
		
	}
	
}