2013-02-19 256 views
0

我有几个流媒体视频。我从video_1.flv开始,在完成之后,video_2.flv正在运行并循环播放,直到用户采取某些操作播放其他电影,例如video_3.flv。所以我需要当video_2.flv在后台播放音频文件sound.mp3女巫将打圈,女巫我设法做到。但我需要他们两个独立运行。因为现在当视频循环播放时,音频正在循环播放。只有当播放video_2.flv时,我才需要音频为playd。谢谢。流媒体音频和视频AS3

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

var ns:NetStream = new NetStream(nc); 
loader.vid.Video_1.attachNetStream(ns); 



var listener:Object = new Object(); 
listener.onMetaData = function(evt:Object):void {}; 
ns.client = listener; 

ns.play("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_1.flv"); 
ns.addEventListener(NetStatusEvent.NET_STATUS, NCListener); 

var clipTimer:Timer = new Timer(4000); 

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"); 
     sound.load(req); 
     shaker(null); 
     } 
}; 

    var sound:Sound = new Sound(); 
    var soundChannel:SoundChannel; 
    var req:URLRequest = new URLRequest("sound.mp3"); 
    sound.addEventListener(Event.COMPLETE, onSoundLoadComplete); 

    function onSoundLoadComplete(e:Event):void{ 
     sound.removeEventListener(Event.COMPLETE, onSoundLoadComplete); 
     soundChannel = sound.play(); 
     soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundChannelSoundComplete); 
    } 

    function onSoundChannelSoundComplete(e:Event):void{ 
     e.currentTarget.removeEventListener(Event.SOUND_COMPLETE, onSoundChannelSoundComplete); 
     soundChannel = sound.play(); 
    } 
loader.button_01.addEventListener(MouseEvent.CLICK, play_video_01); 
loader.button_01.addEventListener(MouseEvent.ROLL_OVER, play_effect_01); 

function play_video_01 (event:MouseEvent){ 

    clipTimer.stop(); 
    ns.play("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_3.flv"); 
    loader.button_01_mc.gotoAndPlay (41); 
} 

回答

0

也许这个教程对你有帮助... 我在AS是新,但我宁愿喜欢整个小号....东西打包成一个(可重复使用)类...

Behavior of a Loaded SWF File versus Behavior of a MovieClip

电贺

啧啧

+0

虽然此链接可以回答这个问题,最好是在这里有答案的主要部件,并提供链接,再ference。如果链接页面更改,则仅链接答案可能会失效。 – Joel 2014-02-12 14:49:28

+0

好点,但你知道的时间...: - /会试图按照你的想法。 – 2014-02-12 15:11:52