In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Youtube ActionScript 3.0 API テスト

Youtube ActionScript 3.0 API テスト
@nki2 (http://wonderfl.net/user/nki2) にもらった。

videoはデビューした同僚のPV
99radioservice - follow her dog
(http://99radioservice.com/top.html)
/**
 * Copyright dimitris.1972g ( http://wonderfl.net/user/dimitris.1972g )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dymG
 */

// forked from nijitaro's Youtube ActionScript 3.0 API テスト
/**
 * Youtube ActionScript 3.0 API テスト
 * @nki2 (http://wonderfl.net/user/nki2) にもらった。
 *
 * videoはデビューした同僚のPV
 * 99radioservice - follow her dog
 * (http://99radioservice.com/top.html)
 */
package {
    
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.system.Security;
    
    
    [SWF(backgroundColor="0x000000", frameRate="30", width="640", height="400")]
    public class Index extends Sprite {
        
        private var player:Object;
        private var loader:Loader;
        
        
        /// init
        public function Index() {
            loader = addChild(new Loader()) as Loader;
            loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit, false, 0, true);
            loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
        }
        
        
        /// events
        private function onLoaderInit(event:Event):void {
            loader.content.addEventListener("onReady", onPlayerReady);
            loader.content.addEventListener("onError", onPlayerError);
            loader.content.addEventListener("onStateChange", onPlayerStateChange);
            loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange);
        }
        
        private function onPlayerReady(event:Event):void {
            // Event.data contains the event parameter, which is the Player API ID 
        
            // 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;

            player.setSize(640, 360);

            // ビデオの頭に黒が入っていたので、0:18から開始
            player.loadVideoById("jWsz4AirHgk", 18, "default");
//            player.pauseVideo();
//            player.cueVideoById("jWsz4AirHgk", 0, "default");
        }
        
        private function onPlayerError(event:Event):void {
            // Event.data contains the event parameter, which is the error code
        }
        
        private function onPlayerStateChange(event:Event):void {
            // Event.data contains the event parameter, which is the new player state
        }
        
        private function onVideoPlaybackQualityChange(event:Event):void {
            // Event.data contains the event parameter, which is the new video quality
        }
                
    }
    
}