I have an HTML5 Progressive Web App (PWA) that I've packaged into the Window Store thanks to PWABuilder. It's a Pandora-like music app that plays audio via the HTML5 audio tag.
The app works fine on Windows 10 until I minimize the app, then the audio stops playing. I want my app to keep playing audio even when minimized.
My first thought is I need to declare the appropriate capabilities in my app manifest. So, in my appxmanifest.xml, I added:
<Capabilities>
<uap3:Capability Name="backgroundMediaPlayback" />
</Capabilities>
But even with the backgroundMediaPlayback capability, it doesn't work; minimizing the app stops the audio.
Looking at the Universal Windows audio sample app, it says this should work:
"Adding the backgroundMediaPlayback capability enables all media playback APIs become background enabled. That means you can use any platform audio APIs, such as MediaPlayer, AudioGraph, XAudio2, and the HTML Audio tag."
If I'm reading that right, it means simply adding the backgroundMediaPlayback capability should make my HTML5 audio tags work in the background. Is there something else I'm missing?
This sounds like the app is being suspended instead of using the Activity Sponsored Execution
mode that's available for apps that declare the backgroundMediaPlayback
capability (MS blog here).
Check to see if your app is being suspended when it's minimized. Were you able to get the sample working?
UPDATE 1
It looks like your MinSDK and Target SDK are set to 10240 (the first version of Windows 10). Update the values to the following:
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.14393.0" MaxVersionTested="10.0.16299.0"/>
UPDATE 2
In addition to the SDK versions, you also need to add the SystemMediaTransportControls. See the 2nd bullet point in under the "Requirements for Background Audio" paragraph in this documentation article.
Resources
I tracked down the different documentation articles that piece this together.