流媒体音频和视频AS3

时间:2013-02-19 16:41:19

标签: actionscript-3 flash

我有几个我正在播放的视频。我从video_1.flv开始,在完成后video_2.flv正在运行并循环,直到用户采取某些操作来播放其他电影,例如video_3.flv。因此我需要在video_2.flv播放后台播放时音频文件sound.mp3将会循环播放,我设法做到了。但我需要他们两个独立运行。因为现在当视频循环播放时,音频正在循环播放。而且只有在播放video_2.flv时我才需要播放音频。谢谢你。

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);
}

1 个答案:

答案 0 :(得分:0)

也许这个教程对你有帮助...... 我是AS的新人,但我更愿意将整个......收集到一个(可重复使用的)课程中......

Behavior of a Loaded SWF File versus Behavior of a MovieClip

迎接