Play audio in Windows 8 apps without a media element?

I want to play audio in a Windows 8 application without using the Media element. The media element must be mapped to the visual tree of each page. Since all pages in my application use background sound, I have to attach the MediaElement in the application frame. All this sucks. I would appreciate it if someone could provide me with pointers to playing audio in a Windows 8 application without this multimedia item that doesn't make sense.

+6
source share
1 answer

You need to set the property to your MediaElement:

<MediaElement x:Name="myMedia" AudioCategory="BackgroundCapableMedia /> 

The contents of this MediaElement will be played even on other pages and paused. You also need to set in the application manifest Background tasks → Audio , that your application supports background sound.

A good tutorial on how to use this feature here:
C # Metro Background Sound
or here:
Play audio in background using BackgroundCapableMedia

+1
source

Source: https://habr.com/ru/post/944031/


All Articles