Skip to main content
Participating Frequently
April 12, 2009
Question

simultanious playback issue

  • April 12, 2009
  • 1 reply
  • 1312 views

Here is my problem:
I have 2 (or more) instances of the same SWF file, and each one runs on a browser window or tab.
A message is sent to all the instances to play the same video. The FLV files are hosted on a web server (so no FMS is involved here).
The first instance to play the movie calls the onStatus function (called when the video state changes) almost immediately after the play() method is executed, but the problem is that, unlike the just mentioned behavior, the other instances take a long while between the execution of the play() method and calling the onStatus function, causing the video to start playing several seconds (even minutes!!) after calling the play() method.

Does any one know what's happening here and how it can be solved?

HERE IS CHUNK OF CODE JUST FOR ILLUSTRATION PURPOSES:

rcn.call("initVideo", null); //sends a message to all clients to execute the initVideo() function

function initVideo(){
     videoStream.play(flvFile);
     var currTime = (new Date).getTime();
}

function onStatus(info){  //executed when the video state is updated
     var elapsedTime = (new Date).getTime() - currTime;
     trace ("Instance " + instanceNumber + ": " + elapsedTime + " seconds elapsed"); //Shows the elapsed time between the execution of play() method and the execution of this method
}

Flash tracer output:
Instance 1: 2.212 seconds elapsed
Instance 2: 40.212 seconds elapsed
Instance 3: 40.831 seconds elapsed

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 12, 2009

if you're trying to stream more than 1 swf simultaneously, it's not going to work.  one will start streaming before the other and occupy most of the bandwidth unless the streams bitrate is less than the user's download rate.

Participating Frequently
April 12, 2009

Well, how can it be accomplished? How can each swf stream the same video simltaneously?

Any ideas?

kglad
Community Expert
Community Expert
April 12, 2009

you'll need to use the netstream class so you can control and monitor the buffer of both streams.

you'll start and immediately stop the play of each.  when both buffers are filled, you can (re) start their play.

but unless the user has sufficient bandwidth to stream both without interruption, you'll need to stop both when one buffer empties and then restart both when both buffers fill.

or there are other ways to work around this like checking the user's bandwidth so you can be reasonably sure that when the buffers fill initially, there won't be a problem with stream interruption.