4 Replies Latest reply on Sep 24, 2009 2:39 AM by flibustier3

    Youtube style buffering


      Is there any way to make YouTube style buffering, like when I press pause - player continues buffering till end?

      But when I just open the video file - it doesn't wait till full buffer and starts playing.

        • 1. Re: Youtube style buffering
          bringrags Level 4

          I believe it works this way now -- are you seeing something different?  If MediaPlayer.autoPlay is true, then playback begins immediately (or as soon as there's enough content present to play).


          One thing we're missing right now is an API for determining how much data has been downloaded, so that you could display a YouTube-style scrub bar (i.e. where the track turns red as the bytes are downloaded).  That's coming in a later milestone.

          • 2. Re: Youtube style buffering
            flibustier3 Level 1

            Seems that I look for something different


            Now I have value to edit - bufferTime. But seems that I don't have something like intelligent buffer, which downloads video forward while I'm viewing it or while I'm on pause. And more - video doesn't start playing when buffer is not full. I can put buffer for a minute, but video won't start untill player downloaded it for 60 sec buffer. (sorry for my English).I need something like - I start playing and it downloading forward (buffer grows up to max video length). But now buffer has only fixed size.

            • 3. Re: Youtube style buffering
              bringrags Level 4

              I think I understand what you're saying.  Sounds like you want to start with a very small buffer (so that the video starts immediately), and grow the buffer over time.  What you could do is start with the default bufferTime value (which is 0.1, I believe), and then adjust the bufferTime value as the buffer fills out.  You could do this based on how much data is in your buffer (i.e. the bufferLength property), or just slowly increase bufferTime as the video plays.  Here's some sample code (caveat: I haven't run this) showing how you might do the latter:


              var timer:Timer = new Timer(3000);
              timer.addEventListener(TimerEvent.TIMER, onTimer);
              function onTimer(event:TimerEvent):void
                   // Only grow the buffer when we're not buffering.
                   if (mediaPlayer.bufferable && !mediaPlayer.buffering)
                        mediaPlayer.bufferTime += 1.0;


              Every 3 seconds, the timer will fire, and the event listener will check the buffer state.  If the video isn't buffering, then it will increment the bufferTime by one.  A more advanced version of this might check MediaPlayer.bufferLength to see whether an increase of bufferTime is safe, or whether it's likely to result in the need to buffer.


              One thing I should point out is that the MediaPlayer.bufferTime and MediaPlayer.bufferLength properties refer to the memory buffer, not the disk buffer.  With progressive video, the download of the video file will proceed (based on your bandwidth) regardless of these properties, and there's not much you can do to control this.


              Hope this helps,


              1 person found this helpful
              • 4. Re: Youtube style buffering
                flibustier3 Level 1

                Thank you for your answer, but I'm working exactly with progressive video and I can't control the progress of loading or even monitor it

                Seems, that I should wait for data transfer trait

                Or somehow extend the ILoadable trait to catch bytesTranfered.