1

我有一个嵌入了 youtube 视频的 Flash 横幅。当用户按下按钮时,横幅会转到特定帧并播放视频。我需要它做的是在视频完成后,将其转发到另一帧。

我用来拉入 youtube 视频的 AS3 如下:

stop();

var player:Object;

Security.allowDomain("www.youtube.com");

var vidctn:Loader = new Loader();
vidctn.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
vidctn.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);

function onLoaderInit(e:Event):void{
addChild(vidctn);
player = vidctn.content;
player.addEventListener("onReady", onPlayerReady);
}

function onPlayerReady(e:Event):void{
player.destroy();
addChildAt(vidctn,0);
player.setSize(304,173);
player.x = 0;
player.y = 40;
player.mute();
player.loadVideoById("Dzz6lUsF19g",0,"large");
}

我想我需要一个事件监听器,可能是 Event.COMPLETE,但我似乎想不出一个。

4

1 回答 1

0

这些是 youtube api 的状态(您只需要 YT_ENDED,但拥有所有状态很好):

        public static var YT_UNSTARTED:int = -1;
        public static var YT_ENDED:int = 0;
        public static var YT_PLAYING:int = 1;
        public static var YT_PAUSED:int = 2;
        public static var YT_BUFFERING:int = 3;
        public static var YT_CUED:int = 5;

添加监听器:

        vidctn.contentLoaderInfo.addEventListener("onStateChange", onPlayerStateChange);

这是功能:

        protected function onPlayerStateChange(event:Event):void {
            trace("youtubePlayer: player state:", Object(event).data);
            if(Object(event).data==YT_ENDED) {
                   //here you can do your stuff
            }
       }
于 2012-12-10T18:17:45.783 回答