Flash Media Server Developer Documentation

About buffering streams

Buffering a video stream helps ensure that the video plays smoothly, without interruption. Buffering manages fluctuations in bandwidth while a video is playing. These fluctuations can occur due to changes in a network connection or server load, or to additional work being done on the client computer.

To create the best experience for users, monitor the progress of a video and manage buffering as the video downloads. You may need to set different buffer sizes for different users, to ensure the best playback experience. One choice is to detect a user's bandwidth (see "Detecting bandwidth") and set an initial buffer size based on it.

While the stream is playing, you can also detect and handle netStatus events. For example, when the buffer is full, the netStatus event returns an info.code value of NetStream.Buffer.Full. When the buffer is empty, another event fires with a code value of NetStream.Buffer.Empty. When the data is finished streaming, the NetStream.Buffer.Flush event is dispatched. You can listen for these events and set the buffer size smaller when empty and larger when full.

Note: Flash Player 9 Update 3 no longer clears the buffer when a stream is paused. This allows viewers to resume playback without experiencing any hesitation. Developers can also use NetStream.pause() in code to buffer data while viewers are watching a commercial, for example, and then unpause the stream when the main video starts. For more information, see the NetStream.pause()entry in the Adobe Flash Media Server ActionScript 2.0 Language Reference or in the ActionScript 3.0 Language and Components Reference.