1

while playing this wav file in windows phone 7 its getting error.

var stream = TitleContainer.OpenStream("TestSound.WAV");
            var effect = SoundEffect.FromStream(stream);
            FrameworkDispatcher.Update();
            effect.Play();

And Its getting this exception on second line of code.

Ensure that the specified stream contains valid PCM mono or stereo wave data.
Arslan Pervaiz
  • 1,575
  • 4
  • 29
  • 62

2 Answers2

1

I've played wav files lots...

What wav file are you trying to play?

Here's a very simple sound I've played before... http://iron7.com/forapp/xylo/x1.wav

I find the audacity tool is particularly useful for editing files into an acceptable format - http://audacity.sourceforge.net/

Stuart
  • 66,722
  • 7
  • 114
  • 165
  • Thanks Alot Stuart Your Sample Wav file runs for me. Can you please tell me how I can convert some mp3 files into wav format that can run on wp7 but I want to keep size low as these files are also be part of app and I dont want to make app size bigger. Please suggest. – Arslan Pervaiz Sep 30 '12 at 07:03
  • For playing mp3 you can use the mediaelement. For converting mp3->wav use http://audacity.sourceforge.net/ but this will increase the size. For more ideas, search on here or ask a new question – Stuart Sep 30 '12 at 07:22
  • XNA has it's own built-in compression for sound effects. [See my answer here](http://stackoverflow.com/a/7025544/165500). – Andrew Russell Sep 30 '12 at 11:25
1

You can use any of .wav files with these format criteria :

Codec: Microsoft PCM Format

Sample Rate: 11025

Channels: 1 (mono) or 2 (stereo)

Bit Depth: 16 Bit

fxbayuanggara
  • 316
  • 3
  • 16