如何在ActionScript同步多路视频流?多路、如何在、视频、ActionScript

由网友(真想掐死寂寞)分享简介:我想同时播放多个视频流。但是,我无法同步这些视频以同样的速度播放。I'm trying to play multiple video streams simultaneously. However, I cannot synchronize these videos to play at the same rate....

我想同时播放多个视频流。但是,我无法同步这些视频以同样的速度播放。

I'm trying to play multiple video streams simultaneously. However, I cannot synchronize these videos to play at the same rate.

----细节--------

---- details --------

我在FLV格式的三次45秒的视频,我用flash.net.NetStream在播放这些视频。我把这些的NetStream中的NetStream.play()的同时(通过使用一个for循环)。然而,这些影片都出不同步,即使所有的视频​​文件在我的本地计算机。

I have three 45-second videos in FLV format and I use flash.net.NetStream to play these videos. I call netstream.play() of these netstream at the same time (by using a for-loop). However, these videos are out-of-sync even all videos files are on my local machine.

例如,当壁钟是在第十第二,第一视频是在第七秒,第二视频是在第十秒,最后视频是在第5秒

For example, when the wall clock is at 10th second, the first video is at 7th second, the second video is at 10th second, and the last video is at 5th second.

我觉得流时,它可能会受不同的抖动延迟。但是,我仍然无法找到解决这个问题的方法。

I think it may be affected by different jitter delays when streaming. However, I still cannot find the way to solve this problem.

推荐答案

Oups ....没看出来2岁......

Oups.... didn't see it was 2 years old......

我觉得你应该尝试preLOAD文件中的每个播放器实例,等待装载完成后,就可以开始视频。依托NetStream的事件并没有那么大(多次相同的通知,或根据文件起到缺少通知....),但它应该工作。

I think that you should try to preload your files in each player instance, wait for the load to be completed and then, you can start the videos. Relying on NetStream event is not so great (several times the same notification, or missing notification depending on the file played....) but it should work.

function Preload() : void {
    aNet              = new NetConnection();
    aNet.connect(null);
    stream                = new NetStream( aNet );
    stream.client     = this;
    stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus, false, 0, true );
    stream.addEventListener(IOErrorEvent.IO_ERROR, errSnd, false, 0, true );
    stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError, false, 0, true );
    stream.play("your file");
}


// Here you wait for the load notification, and then pause the video.
private function onNetStatus( e : NetStatusEvent ) : void {
     switch( e.info.code ) {
      case "NetStream.Buffer.Full" :    
               if (bNotified) return;
               stream.pause();
               // Store that the file is loaded
               bNotified = true;
               // Dispatch an event
               dispatchEvent( new Event("VIDEO LOADED") ); 
       break;               
    }
}

private function errSnd(e: IOErrorEvent ) : void {
// error handling   

}

private function onAsyncError(e: AsyncErrorEvent ) : void {
    // Error handling
}
阅读全文

相关推荐

最新文章