3 Replies Latest reply on Oct 29, 2010 11:34 PM by claygt

    Start Buffering Without Autoplay

    Shaun McFall

      Hello, I'm trying to get my video player to start buffering without also auto-playing. Basically, I want the player to start buffering the video asap, so that, hopefully, by the time they hit the play button, it's buffered enough for them to start watching. I've seen some posts that mention a play-pause sequence, which I do, and that makes it start buffering. The only issue is that eventually causes the TimeEvent.COMPLETE event to fire, which is how I'm determining if the video has finished playing. I tried putting a seek(0) after the pause, but that throws an illegal operation exception; apparently the player can't yet seek. If I wrap the play-pause sequence in an if that checks canSeek, it never gets called. Is there a better way to be doing any part of this process? Is the TimeEvent.COMPLETE event not the right thing to be using to determine if the player has finished playing? Is there an autoBuffer flag that I'm just missing?



        • 1. Re: Start Buffering Without Autoplay
          bringrags Level 4

          If you do a play-pause sequence, then you shouldn't get a TimeEvent.COMPLETE event.  If you do, then that means that the pause isn't happening.  One thing you could try is to listen for the playStateChange event before calling pause.  You could also check that canPause is returning true, as pause() won't work if it's not.

          • 2. Re: Start Buffering Without Autoplay
            Shaun McFall Level 1

            So I discovered another issue I was having: it was calling the play-pause sequence multiple times, which seems like a bad idea. It's not just calling it once, but it never gets into the play state. This is the code I have for the play-pause sequence:

            if (player.canPlay && player.canPause && !hasPlayPaused) {
                 hasPlayPaused = true;
                 trace(">>> play-pause start");
                 var v:Number = player.volume;
                 player.volume = 0;


                 player.volume = v;
                 trace(">>> play-pause done");


            And this is the output:

            >>> play-pause start
            >>> 0: paused
            >>> play-pause done

            It's only changing its state once. If I then hit play, the state change event doesn't fire, but it does start to play. Same when I then hit pause. The next time I hit play it does fire, though. I have the play-pause sequence in a timer, because I couldn't find an event that allowed it to happen. The canPlay event never fired. Any insights given this information? I feel like I'm probably doing something terribly wrong.

            • 3. Re: Start Buffering Without Autoplay

              I'm doing something similar -- If you listen for the CAN_SEEK_CHANGED event, then in that listener, make sure canPlay = true, you can do a play/pause/seek(0) sequence that will prep your video for play without playing it.