Actionscript 3 独立于as3的流式音频和视频
我有两个功能。正如你所看到的,第一个是视频流(巫婆在循环),第二个是音频流(巫婆也在循环)。所以我需要在视频播放时,音频开始运行并独立循环,因为我的音频长度大于视频长度。你知道我该怎么做吗。请使用密码Actionscript 3 独立于as3的流式音频和视频,actionscript-3,flash,stream,Actionscript 3,Flash,Stream,我有两个功能。正如你所看到的,第一个是视频流(巫婆在循环),第二个是音频流(巫婆也在循环)。所以我需要在视频播放时,音频开始运行并独立循环,因为我的音频长度大于视频长度。你知道我该怎么做吗。请使用密码 function NCListener(e:NetStatusEvent){ if (e.info.code == "NetStream.Play.Stop") { ns.play("http://media.easyads.bg/ads/display_ads_ric
function NCListener(e:NetStatusEvent){
if (e.info.code == "NetStream.Play.Stop") {
ns.play("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_2.flv");
shaker(null);
}
};
var sound:Sound = new Sound();
var soundChannel:SoundChannel= new SoundChannel();
sound.addEventListener(Event.COMPLETE, onSoundLoadComplete );
function onSoundLoadComplete(e:Event):void{
sound.removeEventListener(Event.COMPLETE, onSoundLoadComplete);
soundChannel = sound.play(0, 9999);
soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundChannelSoundComplete);
}
function onSoundChannelSoundComplete(e:Event):void{
e.currentTarget.removeEventListener(Event.SOUND_COMPLETE, onSoundChannelSoundComplete);
soundChannel = sound.play(0, 9999);
}
首先,你不需要
soundChannel.addEventListener(Event.SOUND\u COMPLETE,onSoundChannelSoundComplete)代码>
它会在声音结束时触发,但由于它是循环的,因此无需再次播放
首先,你需要移动这条线
soundChannel = sound.play(0, 9999);
并将其放在您的ns之后。播放。因此,声音将在视频开始时立即开始。
然后,为了防止视频启动时再次循环,只需检查soundChannel是否存在:
if (soundChannel == null)
soundChannel = sound.play(0, 9999);
请注意,没有办法使您的声音与视频保持同步,这完全取决于flashplayer的意愿。是的,我知道。但是,如果我像你说的那样,当视频循环时,它会在第一次播放时再次播放声音(因为它还没有完成),而且会变得非常混乱!这就是为什么我需要同时打两个球,但要独立循环。这不起作用。当视频循环时,它会在同一音频上再次播放音频。请确保仅在类级别声明一次soundChannel变量,并删除`var soundChannel:soundChannel=new soundChannel()`