This sample demonstrates how to play audio on Windows Phone 8.1 when your app is not the foreground task.
You can write apps for Windows Phone 8.1 that play audio in the background. This means that even after the user has left your application by pressing the Back button or the Start button, or changes to another app with the task switcher, your app can continue to play audio.
Scenarios for background audio playback include:
- Long-running playlists The user briefly brings up the foreground app to select and start a playlist, after which the user expects the playlist to keep going continuously in the background.
- Using task switcher The user briefly brings up the foreground app to start playing some audio, then switches to another open app using the task switcher. The user expects the audio to continue playing in the background.
The sample consists of a solution that contains 3 projects:
- The main user interface for the audio player
- A sample background audio task
- A simple playlist manager
Note This sample requires Windows 8.1 and Microsoft Visual Studio 2013 with Update 2 or later.
To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.
To obtain an evaluation copy of Visual Studio 2013 , go to Visual Studio 2013 . After you install Visual Studio 2013, update your installation with Update 2 or later.
Operating system requirements
Build the sample
- Start Visual Studio Express 2013 for Windows --> and select File > Open > Project/Solution.
- Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio Express 2013 for Windows Solution (.sln) file.
- Press F7 or use Build > Build Solution to build the sample.
Run the sample
To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.