user1183530
user1183530

Reputation: 11

BackgroundAudioPlayer- Buffering & MediaStreamSource

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.

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

Upvotes: 0

Views: 848

Answers (2)

Paul Annetts
Paul Annetts

Reputation: 9604

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.

Upvotes: 0

Matt Lacey
Matt Lacey

Reputation: 65586

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.

Upvotes: 1

Related Questions