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.
Asked
Active
Viewed 646 times
6
-
+1 thank you for this question because I would do it sooner or later. I thought of using DirectX but I have no experience with it so I don't know if it is easily doable. – letiagoalves May 01 '13 at 11:31
-
Have you looked at this? http://stackoverflow.com/questions/9564544/play-audio-in-background-by-use-backgroundcapablemedia – N_A May 14 '13 at 20:08
-
The question does not help me. The MediaElement should still be added to the XAML to play audio. I am trying to play audio without any changes to the XAML. – vijayst Jul 07 '13 at 17:09
1 Answers
1
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

Community
- 1
- 1

Martin Suchan
- 10,600
- 3
- 36
- 66
-
MediaElement is a pain. You have to add it to the XAML. Without adding it in the XAML you cannot play audio. I need it for each and every page. – vijayst Jul 07 '13 at 17:08