Play Background Audio in Your Windows Phone Apps
Introduction
Windows Phone Mango introduced support for a background audio feature, which makes it possible to have another application running in the foreground while the user continues listening to the latest musical sensation.
A Windows Phone application that plays Background Audio leverages the "background agents" feature. To build such an application, you can either implement it to play files or to stream. To build a streaming background audio application, you need to use the MediaStreamSource class (which resides in the System.Windows.Media namespace).
Architecture
Media on the Windows Phone is played through the Zune Media Queue. To play content, the application needs to call method on the BackgroundAudioPlayer class, which interacts with the Zune Media Queue to play audio.
Hands-On
To start with, open Visual Studio and create a new Windows Phone application titled WPBackgroundAudioDemo. Click OK
(Full Size Image)
Figure 1: Create a new Windows Phone application
When prompted, select Windows Phone OS 7.1 as the target OS and click OK.
(Full Size Image)
Figure 2: Select the Windows Phone Platform
Next, add a new Project of type "Windows Phone Audio Playback Agent" to the solution, titled AudioPlaybackAgentDemo.

