In reality, these class names are somewhat misleading. AudioPlayerAgent is actually designed to play URI-based audio in the background, whether locally or remote. What that means is that you can supply either a local path pointing to a media file in isolated storage, or the URL of a remote media file. The catch is, the media file must have a supported audio format, which is either MP3 or WAV.
So in your foreground application or in the agent, you can create an audio track like so :
Then you can load and play the media file regardless of location :
You can actually mix and match between local files in isolated storage, and remote files in a same playlist :
The background player will play all these files in the same manner.
For local files, make sure the audio files added to your project are copied into isolated storage before trying to set the track on the background player. MSDN provides an example for doing that, which can be called at application startup. I’ve tweaked it so it reads the playlist songs from a xml file, and copies only the local meia files to isolated storage :
Here’s the sample xml playlist :
So to recap, the AudioPlayerAgent has more capabilities than can be guessed from the name. Use it in your apps for common scenarios of playing mp3 or WMA local or remote audio files in the background.