Youtube API AS3 - 是否可以只有两个按钮来控制YouTube视频的停止/播放和静音/取消静音

时间:2014-10-22 20:45:37

标签: actionscript-3 youtube

以下是取自https://www.youtube.com/watch?v=GQnoOcPbgx0的AS3代码。目前有5个按钮。我想 -

  • btnPlay来控制player.playVideo();和player.pauseVideo();
  • btnMute来控制player.mute();和player.unMute();
  • 按钮仅在翻转时出现

您可以在此处观看演示(翻转左侧橙色按钮以观看视频)http://pages.areadevelopment.com/advertisers/MDA/index.html

如果有人可以提供帮助,我们将不胜感激。 谢谢! CE

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.ui.MouseCursor;

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

var player:Object;


var loader:Loader = new Loader();
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
loader.x = 344;    
loader.y = 34;

function onInit(e:Event):void{

    addChild(loader);

    player = loader.content;

    player.addEventListener("onReady",onPlayerReady);

}

function onPlayerReady(e:Event):void{

    player.setSize(330,225);

    player.loadVideoById("nHnXVBNizDQ",0);  

}

btnPlay.addEventListener(MouseEvent.CLICK, playVid);

    function playVid(e:MouseEvent):void{

    player.playVideo();

}

btnPause.addEventListener(MouseEvent.CLICK, pauseVid);

function pauseVid(e:MouseEvent):void{

    player.pauseVideo();

}

btnStop.addEventListener(MouseEvent.CLICK, stopVid);

function stopVid(e:MouseEvent):void{

    player.stopVideo();

}

btnMute.addEventListener(MouseEvent.CLICK, muteVid);

function muteVid(e:MouseEvent):void{

    player.mute();

}

btnUnmute.addEventListener(MouseEvent.CLICK, UnmuteVid);

function UnmuteVid(e:MouseEvent):void{

    player.unMute();

}

0 个答案:

没有答案