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.