Syncing problems with multiple flvs
Is it possible to sync flv videos? I'm playing a few videos simultaneously, and they are inconsistently out of sync. If I add a button that seeks all of the videos to 0, they may o开发者_StackOverflow社区r may not be in sync. When they're out of sync, it's only a fraction of a second, but for this application, a fraction of a second is very noticeable. Can we get frame-accurate syncs?
For reference, here's the stripped-down code to play the vids. (It's just a standard netstream call)
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns1:NetStream = new NetStream(nc);
vid_1.attachNetStream(ns1);
ns1.play("vid1.flv");
ns1.pause();
ns1.seek(0);
ns1.addEventListener(NetStatusEvent.NET_STATUS, netstat);
var ns2:NetStream = new NetStream(nc);
vid_2.attachNetStream(ns2);
ns2.play("vid2.flv");
ns2.pause();
ns2.seek(0);
ns2.addEventListener(NetStatusEvent.NET_STATUS, netstat);
function netstat(stats:NetStatusEvent) {
//trace(stats.info.code);
}
var netClient:Object = new Object();
netClient.onMetaData = function(meta:Object){
//trace(meta.duration);
};
ns1.client = netClient;
ns2.client = netClient;
ns1.resume();
ns2.resume();
And I have a button:
btn_play.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
ns1.seek(0.0);
ns2.seek(0.0);
};
Clicking the button restarts the videos, sometimes in sync, sometimes not.
Any way to consistently get them in sync?
Thanks
You might consider pausing both videos until the "NetStream.Seek.Notify" status event has fired off for both videos. It fires when the video has finished seeking to its intented timecode.
精彩评论