I want to play audio in a Windows 8 app without using the Media element. Media Element needs to be attached to the Visual Tree of each page. Since all pages in my app use background audio, I have to attach the MediaElement in the App frame. The whole thing kind of sucks. I will appreciate if someone can provide me pointers to play audio in Windows 8 app without this Media element non-sense.
You need to set the property on your MediaElement:
<MediaElement x:Name="myMedia" AudioCategory="BackgroundCapableMedia />
The content of this MediaElement will then play even on other pages and when your app is suspended. You also need to set a capability Background Tasks -> Audio in the app manifest that your app supports background audio.
Nice tutorial how to use this feature is here:
Background Audio c# Metro
or here:
Play audio in background by use BackgroundCapableMedia
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With