4 Replies Latest reply on Jun 24, 2010 1:20 PM by bringrags

    Noob - Setting up the buffer



      I'm not sure of the extent of my question but can anyone point me toward some sample files / tutorials that explain how to set up the buffer indicator? I presume this question could break off into multiple genre's of buffering (ie. progressive buffering, streaming, dynamic streaming, etc). I'm not sure where to start or if most of this is already built into the OSMF framework. If someone could suggest a starting point that'd be great! Thanks again!

        • 1. Re: Noob - Setting up the buffer
          bringrags Level 4

          When you say "buffer", do you mean the download progress of a progressive video file (e.g. the red scrub track in the YouTube player), or the ability to control the size of the buffered data (i.e. NetStream.bufferTime)?  For the former, you can use MediaPlayer.bytesLoaded/bytesTotal and the corresponding change events to build your UI.  For the latter, you can use MediaPlayer.bufferTime/bufferLength and the corresponding change events.  Feel free to follow up with more specific questions.

          • 2. Re: Noob - Setting up the buffer
            foolish3737 Level 1

            Yeah, both items. As for the download progress, what change events would I listen for? Also, I trace out the MediaPlayer.bytesLoaded, MediaPlayer.bytesTotal and both are returning 0. That can't be right?

            • 3. Re: Noob - Setting up the buffer
              foolish3737 Level 1

              Scratch my question about MediaPlayer.bytesLoaded, MediaPlayer.bytesTotal. I didn't realize I was using a streaming video when I needed a progressive video for those values to take proper effect. So, I understand how the progressive download progress works. Although, I have my download indicator updating on CURRENT_TIME_CHANGE, which, I'm sure is prolly not the best listener to update the buffer on. What listener should I attach to the progressive download function?


              As for streaming videos, I understand your comments about MediaPlayer.bufferTime / MediaPlayer.bufferLength but again, what listener should be attached to the function? Also, I don't grasp how to apply this particular bit of code to the UI. Any suggestions would be great! Thanks again Brian.

              • 4. Re: Noob - Setting up the buffer
                bringrags Level 4

                For the progressive download case, you can listen for LoadEvent.BYTES_LOADED_CHANGE on the MediaPlayer.


                For the buffer, typically you don't represent these properties in the UI (since they're typically not relevant to the user experience, whereas the download status is).  The exception being that you might want to show a "Buffering" indicator when the content is being buffered, so that the user understands why playback has temporarily halted.  For that case, you can listen for BufferEvent.BUFFERING_CHANGE, or to MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE (which represents the overall state of the MediaPlayer).