Cloud Media Lab Posted December 3, 2012 Share Posted December 3, 2012 I have two videos of identical length that I need to play in sync. Occasionally they do loop in sync but are most often offset by some small amount. Unfortunately this is very noticeable in my application. example: video1.addEventListener(VideoLoader.VIDEO_COMPLETE, function():void { video1.gotoVideoTime(0, true); video2.gotoVideoTime(0, true); }); Any suggestions, please? Link to comment Share on other sites More sharing options...
GreenSock Posted December 4, 2012 Share Posted December 4, 2012 The challenge is that the way Flash handles video involves a buffering process which can be a bit unpredictable. Imagine having two browser windows open that are both set to play the same YouTube video and you click the "reload" button on the browser simultaneously - the videos probably wouldn't be perfectly synced. The processor and network and memory all have to work together and there can be little hang-ups in any of those. One thing you could try is to pause both videos (when you want to loop) and then gotoVideoTime(0) for both and listen for the BUFFER_FULL event to be dispatched for both of them. Once you receive BOTH, you can playVideo(). Link to comment Share on other sites More sharing options...
Cloud Media Lab Posted December 4, 2012 Author Share Posted December 4, 2012 Great suggestion, it appears to be working well. Thanks! Snippets of code... video1buffer = new NativeSignal(video1, VideoLoader.VIDEO_BUFFER_FULL, LoaderEvent); video2buffer = new NativeSignal(video2, VideoLoader.VIDEO_BUFFER_FULL, LoaderEvent); video1buffered = false; video2buffered = false; video1.addEventListener(VideoLoader.VIDEO_COMPLETE, function(event:LoaderEvent):void { videoSeek(0); }); videoSeek(0); public function videoSeek(time:Number):void { //Cc.info( "videoSeek("+time+")" ); video1buffered = false; video2buffered = false; video1.pause(); video2.pause(); video1buffer.addOnce(videoBuffered); video2buffer.addOnce(videoBuffered); video1.gotoVideoTime(time); video2.gotoVideoTime(time); } public function videoBuffered(event:LoaderEvent):void { if (event.target == video1) video1buffered = true; if (event.target == video2) video2buffered = true; if (video1buffered && video2buffered) { video1.playVideo(); video2.playVideo(); } } 1 Link to comment Share on other sites More sharing options...
Cloud Media Lab Posted December 4, 2012 Author Share Posted December 4, 2012 Turns out it only works sometimes. Original task was to use two halves of a panoramic video to create a 360 degree view... a video that wraps on its left and right edges. But the effect breaks with any time shift. I'm going to try using a single super wide video instead. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now