Play Background Sound and Sound Effect in Windows Phone 8

后端 未结 2 1809
再見小時候
再見小時候 2020-12-22 04:09

I have researched a lot on playing sounds for Windows Phone 8 devices and found multiple solutions but they don\'t quite match my case.

What I need : I\'m writing an

2条回答
  •  有刺的猬
    2020-12-22 05:08

    In practice, MediaElement is has some gotchas like the visual tree requirement. There are ways to get around it, but they are not optimal. I would suggest scrapping using MediaElement and use XAudio2 instead. It is native so default usage would be in c++, but you can also use SharpDX to access this framework from C#.

    The advantage of XAudio2 is that you would not need to worry about sound dropping out when navigating around since it is not dependent on the UI. Another advantage is you could have one SourceVoice for handling your background audio, and other SourceVoices for handling sound effect playback. This all fits well within the model of usage the framework was designed for.

提交回复
热议问题