gpt4 book ai didi

actionscript-3 - onPlayStatus as3

转载 作者:行者123 更新时间:2023-12-02 07:46:08 25 4
gpt4 key购买 nike

这是新手。使用此代码查看多个 netstream 事件。想要使用 onPlayStatus 循环播放“flv/intro.flv”,对于其余视频,我希望他们在播放完后返回到 intro.flv,但我找不到任何有用的东西.任何人都可以提供该功能的链接或帮助吗?到目前为止,这是我的代码:

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);

var metaDataListener:Object = new Object();
metaDataListener.onMetaData = function(meta:Object){
}

ns.client = metaDataListener
var myVideo:Video = new Video(800, 600);
myVideo.x = 0;
myVideo.y = 0;
addChild(myVideo);
setChildIndex(myVideo, 0);
myVideo.attachNetStream(ns);
ns.play("flv/intro.flv");

duetBTN.addEventListener(MouseEvent.CLICK, playVideo1);
vantageBTN.addEventListener(MouseEvent.CLICK, playVideo2);
cabrioBTN.addEventListener(MouseEvent.CLICK, playVideo3);
classicBTN.addEventListener(MouseEvent.CLICK, playVideo4);
laundryBTN.addEventListener(MouseEvent.CLICK, playVideo5);
resourceBTN.addEventListener(MouseEvent.CLICK, playVideo6);
industryBTN.addEventListener(MouseEvent.CLICK, playVideo7);
homeBTN.addEventListener(MouseEvent.CLICK, playVideo8);
function playVideo1(e:MouseEvent):void {
ns.play ("flv/duet.flv");
}
function playVideo2(e:MouseEvent):void {
ns.play("flv/vantage.flv");
}
function playVideo3(e:MouseEvent):void {
ns.play("flv/cabrio.flv");
}
function playVideo4(e:MouseEvent):void {
ns.play("flv/classic.flv");
}



function playVideo5(e:MouseEvent):void {
ns.play("flv/laundry.flv");
}
function playVideo6(e:MouseEvent):void {
ns.play("flv/resource.flv");
}
function playVideo7(e:MouseEvent):void {
ns.play("flv/industry.flv");
}
function playVideo8(e:MouseEvent):void {
ns.play ("flv/intro.flv");
}

最佳答案

您可以将事件监听器附加到 NetStream 对象,以检测视频何时播放完毕。

var introPlayer:NetStream = new NetStream(nc); // nc refers to shared net connection declared earlier
var introVid:Video = new Video(800, 600);
ns.addEventListener(NetStatusEvent.NET_STATUS, checkStreamStatus);

function checkStreamStatus(e:NetStatusEvent):void {
switch (e.info.code) {
case "NetStream.Play.Complete":
playIntro();
break;
}
};

function playIntro():void {
addChild(introVid);
introVid.attachNetStream(introPlayer);
introPlayer.play("flv/intro.flv");
}

已完全更改代码以匹配您最初使用的设置。这就是你应该做的,对之前的回答表示歉意。不过,这是正确的做法。

关于actionscript-3 - onPlayStatus as3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6884699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com