BackgroundAudioPlayer- Buffering & MediaStreamSource

852 views Asked by At

I have created a MediaStreamSource to decode an live internet audio stream and pass it to the BackgroundAudioPlayer. This now works very well on the device. However I would now like to implement some form of buffering control. Currently all works well over WLAN - however i fear that in live situations over mobile operator networks that there will be a lot of cutting in an out in the stream. What I would like to find out is if anybody has any advice on how best to implement buffering.

  • Does the background audio player itself build up some sort of buffer before it begings to play and if so can the size of this be increased if necessary?

  • Is there something I can set whilst sampling to help with buffering or do i simply need to implement a kind of storeage buffer as i retrieve the stream from the network and build up a substantial reserve in this before sampling.

What approach have others taken to this problem? Thanks, Brian

2

There are 2 answers

1
Matt Lacey On

One approach to this that I've seen is to have two processes managing the stream. The first gets the stream and writes it a series of sequentially numbered files in Isolated Storage. The second reads the files and plays them.
Obviously that's a very simplified description but hopefully you get the idea.

0
Paul Annetts On

I don't know how using a MediaStreamSource might affect this, but from experience with a simple Background Audio Player agent streaming direct from remote MP3 files or MP3 live radio streams:

  • The player does build up a buffer of data received from the server before it will start playing your track.
  • you can't control the size of this buffer or how long it takes to fill that buffer (I've seen it take over a minute of buffering in some cases).
  • once playback starts if you lose connection or bandwidth goes so low that your buffer is emptied after the stream has started then the player doesn't try and rebuffer the audio, so you can lose the audio completely or it can cut in or out.
  • you can't control that either.

Implementing the suggestion in Matt's answer solves this by allowing you to take control of the buffering and separates download and playback neatly.