Best way to play two audio files simultaneously in Windows Phone 8

一曲冷凌霜 提交于 2019-11-29 08:41:17

You could try to do it through MediaFoundation.MediaEngine (see "Supported Microsoft Media Foundation APIs for Windows Phone 8" for guidelines on how to initialize it correctly on WP8). In SharpDX there is a Win8 samples MediaPlayerApp that could be used as a starting point to play only audio (remove all the d3d part and apply guidelines for WP8). There is also a usage of it in MonoGame MediaPlayer class.

Concerning playing multiple WAV with SharpDX at the same time, it is perfectly possible with XAudio2, and SharpDX doesn't have any limitation concerning XAudio2.

There is only a huge concern about the WP8 CLR Garbarge collector that seems to block all native threads when it is collecting, including native audio threads like XAudio2, and that could cause audio stuttering. There is nothing we can do about this, as this is an issue with the OS and the scheduling of threads with .NET.

I have also some doubt about the ability of WP8 to decode two MP3 in realtime... Let us know if you have some results.

Solution : Hi, I was developing a WP8 App and i needed multiple sounds to play simultaneously, i used the XNA framwork. here is the link

http://msdn.microsoft.com/en-us/library/ff842408.aspx

and then play ur sound files like this...

SoundEffect Sound = SoundEffect.FromStream(Application.GetResourceStream(new Uri("Assets/Sounds/wav/sound.wav", UriKind.Relative)).Stream);
Sound.Play();

For looping...

SoundEffectInstance Sound = SoundEffect.FromStream(Application.GetResourceStream(new Uri("Assets/Sounds/wav/sound.wav", UriKind.Relative)).Stream).CreateInstance();
Sound.IsLooped = true;
Sound.Play();

Note: the files must be in ".wav" (PCM, 8 or 16-bit, 8KHz to 48KHz, mono or stereo) format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!