WWW FAQs: Why is there a delay before my streaming music plays?

2006-02-14: Even if you have embedded your MP3 or other audio file so that it plays in a "streaming" fashion as it downloads from the server, there is still a delay in the beginning. That's because the player must first "buffer" a few seconds of music to protect against the brief delays that are so common on the Internet.

If your player starts playing the music instantly, and then a two-second delay of service between the web browser and the web server begins, there will be a two-second pause in the music. And that sounds awful. Little delays like this happen all the time, so this would be unacceptable.

On the other hand, if the player "buffers" music for the first five seconds, then it can "ride out" a two-second delay and then catch up and get ahead again when the connection improves.

Another reason for the delay: what if the end user's Internet connection is very slow, such as a dialup modem connection? Alternatively, what if the web server is overloaded by too many listeners? Then the connection will never be able to keep up, and streaming playback is a mistake. The player should instead wait for the whole song to download before it begins playing.

With a five-second delay at the beginning, the player can usually detect this situation. If only two seconds of music arrive in those five seconds, that's a big clue that the connection is too slow for streaming music.

If the connection improves, and the player does get well ahead of "real time," streaming playback may start later.

For more information, see how do I play streaming audio on a web page?

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!