如何在ActionScript同步多路视频流? [英] How to synchronize multiple video streams in ActionScript?

查看:218
本文介绍了如何在ActionScript同步多路视频流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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
}

这篇关于如何在ActionScript同步多路视频流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆