Windows phone 8 xaudio2 wav file issue

我是研究僧i 提交于 2020-01-05 10:08:33

问题


I want play a wav file with XAudio2, I have searched on the internet and have some example projects like this: C# XAudio2 Sound Playback for Windows Phone or this: Play wav example but all those playing special wav files, if I replace my wav (converted to MS ADPCM, mono) then CreateSourceVoice return HRESULT 0x88960001. So what are specials of those wav files? or any other methods to play Wav file with xaudio2 (I'm working on windows phone 8)


回答1:


According to this article, the XAudio2 only supports a subset of the MS ADPCM format: http://msdn.microsoft.com/en-us/library/windows/desktop/ee415711(v=vs.85).aspx

You have to use the adpcmencode tool in the Windows 8 SDK to compress it into something useable




回答2:


So the standard way of playing both sound effects and background music is using the XNA library.

I wrote a blog post on playing async sound in the windows phone that is pretty straight forward

Basically it says this

using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework;

static Stream stream1 = TitleContainer.OpenStream("soundeffect.wav");
static SoundEffect sfx = SoundEffect.FromStream(stream1);
static SoundEffectInstance soundEffect = sfx.CreateInstance();

public void playSound(){
    FrameworkDispatcher.Update();
    soundEffect.Play();
}

Doesn't get any easier than that. To get specific wav requirements look at the MSDN page for supported formats

I also posted a working solution for download on my blog post.

Good luck!



来源:https://stackoverflow.com/questions/20124685/windows-phone-8-xaudio2-wav-file-issue

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