Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play audio in Windows 8 apps without Media element?

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.

like image 564
vijayst Avatar asked May 01 '13 11:05

vijayst


1 Answers

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

like image 91
Martin Suchan Avatar answered Nov 06 '22 12:11

Martin Suchan