February 2015
Intermediate to advanced
768 pages
26h 24m
English
As explained in Chapter 13, “Audio, Video, and Speech,” if you switch away from your app while it plays an audio file, the audio instantly fades out. When you switch back, it fades back in. If you want the audio to continue being audible while your app is offscreen, you need to do three simple things:
1. Set the AudioCategory appropriately on the MediaElement playing the audio.
2. Add an appropriate Background Tasks declaration to your package manifest.
3. Write some code to keep the MediaElement in sync with a class called SystemMediaTransportControls.
MediaElement’s AudioCategory property can be set to influence how Windows treats the audio. To enable audio to play in the background, you must set ...
Read now
Unlock full access