15 Replies Latest reply on Apr 13, 2009 4:11 PM by cperez1000

    simultanious playback issue


      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?



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

      function initVideo(){
           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

        • 1. Re: simultanious playback issue
          kglad Adobe Community Professional & MVP

          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.

          • 2. Re: simultanious playback issue
            cperez1000 Level 1

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

            Any ideas?

            • 3. Re: simultanious playback issue
              kglad Adobe Community Professional & MVP

              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.

              1 person found this helpful
              • 4. Re: simultanious playback issue
                cperez1000 Level 1

                Thanks for your prompt response!


                I'm not actually too worried about the streams being interrupted, but about the time they take just to start after the first instance does.

                The client's bandwidth is more or less high, I'm not sure about the server's.

                I’m using the NetStream class and am starting and immediately stopping the play of each and waiting for the buffer to be full.


                Here is part of the actual code:


                private var connection_nc:NetConnection;
                private var strmVideo:NetStream;

                private var VideoNumber = 1; //changes depending on the video selected
                private var vdVideo:Video; //already part of the movie clip
                private var videoStatus = null;
                private var VIDEO_BUFFER_TIME = 2.0;
                private var STATUS_INIT = 1;


                //IN THE CONSTRUCTOR
                connection_nc = new NetConnection();
                strmVideo = new NetStream(connection_nc);
                this.strmVideo.onStatus = mx.utils.Delegate.create(this, infoStatus);


                private function initVideo(){ //called after video is selected
                  this.strmVideo.play("/videos/"+ this.videoNumber + ".flv");
                  this.currTime = (new Date()).getTime();


                  this.videoStatus = STATUS_INIT;

                private function infoStatus(info){
                  trace("Time ellapsed since play() was called: " + ((new Date()).getTime() - this.currTime));
                  this.currTime = null;


                  switch (info.code){
                    case "NetStream.Buffer.Full":{
                      if (this.videoStatus == STATUS_INIT){

                    //... some more code is here

                • 5. Re: simultanious playback issue
                  kglad Adobe Community Professional & MVP

                  i don't see anything in your code that coordinates the two swfs.  i thought that was the key issue:  both flvs should be coordinated.

                  • 6. Re: simultanious playback issue
                    cperez1000 Level 1


                    Sorry, I still don't see how this coordination can solve the problem.

                    I’m just getting the following status changes (no flush, no empty, no close, no anything else):





                    As I mentioned I’m not using FMS, although I can consider using it.


                    I tried sending the message to the other swfs to play the video only after the buffer was full, but the problem remains.


                    case "NetStream.Buffer.Full":{
                      if (this.videoStatus == STATUS_INIT){

                        this.msConnection.call("initVideo", null);


                    I’ll modify the question to make it less complicated:

                    If I just want to make a simple video player (no FMS) and allow multiple clients to watch videos (like every video player should work I suppose), how can it be done, without having all clients to wait for the first instance to fully load the video, supposing that it’s hosted on a regular and simple web server (ups and downs on the ) and that the clients may have any bandwidth?

                    The other option I’m thinking is to host all videos under FMS and use some compression. I’ve never used compression before, so it’d be great if I can get some light on using compression before looking everywhere.

                    • 7. Re: simultanious playback issue
                      kglad Adobe Community Professional & MVP

                      your modified question doesn't look like the same question as you first posed.  actually, your modified question looks like you just want to create a flv player.  i don't see anything about coordinating videos.

                      • 8. Re: simultanious playback issue
                        cperez1000 Level 1

                        It is basically the same question, because like I mentioned, I'm not using FMS for streaming the video, I'm just using it to send a message to all the clients to play the same video automatically, but the videos are hosted on the webserver and the connection is made to null


                        The player I created seems to work fine, but when other instances of the swf try playing the same video (haven't tested with another one) they would just take a very long time to start playing, which I had mentioned by saying that the time taken by these other instances between calling their own play() method and just triggering their onStatus() function is too long.

                        So another way to put is to know how these instances can start as soon as the video is played without waiting for the video to fully load in the first instance of the player. It does not matter if the lower bandwith makes all the streams take longer to play, as long as they start immediately and take the same time playing when the same video is loaded.



                        • 9. Re: simultanious playback issue
                          kglad Adobe Community Professional & MVP

                          outside of testing, will this video be played by anyone in more than one browser window at any one time?

                          • 10. Re: simultanious playback issue
                            cperez1000 Level 1

                            I wouldn't expect that, but if it can be done with YouTube , why can't with this player?

                            • 11. Re: simultanious playback issue
                              kglad Adobe Community Professional & MVP

                              it's not done on youtube and it's looking less and less like this is a flash issue and more and more like a misunderstanding about how files are served over the internet.


                              on youtube and everywhere else, many people can view the same video simultaneously, but the video is not synched with each viewer AND, more importantly, those viewers are on different host computers using different download pathways.


                              you can't test what 2 different people on 2 different systems with 2 different internet paths to your server are going to see by using one internet path.  and that seems to be what you're trying to do.


                              a better test would be to call a friend and have them navigate to your video at (about) the same time you navigate there.  that will tell you something about your server's upload capacity.  if it's not satisfactory, contact your hosting company about purchasing more instantaneous bandwidth so you can serve more bytes/second.

                              • 12. Re: simultanious playback issue
                                cperez1000 Level 1

                                You can have several instances in the same machine of YouTube’s player playing the same video almost simultaneously (even if the video is not cached), without having to wait for the rest to start until the first instance finishes loading. Besides that, basically the only “relevant” difference is that my player plays the same video (almost simultaneously) by starting the play automatically, while the same test on YouTube’s player was done manually just by opening two browser tabs almost simultaneously.


                                I have some options on what the problem might be, including server bandwidth, client bandwidth, having the instances running on the same machine or browser, and so on, but like I mentioned in a previous post: I’m not worried if the lower bandwidth makes all the streams take longer to play, as long as they start immediately and take a similar time playing when the same video is loaded (that regardless if they are in the same machine).



                                • 13. Re: simultanious playback issue
                                  kglad Adobe Community Professional & MVP

                                  it's probable that youtube has more upload bandwidth than your server.  and youtube uses pseudo-streaming with lighttpd.


                                  in any case, because you're not concerned about bandwidth issues, i infer this thread is closed?

                                  • 14. Re: simultanious playback issue
                                    cperez1000 Level 1

                                    I'm sure there is more to add to this, but I guess we can call it closed since you are the only one responding to all the posts

                                    Thanks for your time.

                                    • 15. Re: simultanious playback issue
                                      kglad Adobe Community Professional & MVP

                                      you're welcome.