Audio Streaming in Windows8

Tag: windows-8 Author: duankui Date: 2012-07-21

I want some help on streaming an audio content on Windows8.I have several URL's which i need to play.Not sure if there is any ready to use API for this or anything else.

Can anyone please help ?

Best Answer

Try this:

Combine this with this.

Basically you create an instance of the MediaElement class with a URI like Uri targetUri = new Uri(@"http://www.bing.com"); which points to your audio.

Since you mentioned "several URLs" you'll need to create some sort of "playlist" (which may just be a collection of URLs). You can subscribe to the MediaEnded event of the MediaElement to know when to go to the next track. You'll also want to subscribe to the MediaFailed event in case the network goes down, the audio file is deleted or the audio file is using an unsupported codec.

Finally, consider adding support for audio to continue running in the background even when your application is not focused. This thread should help.