For size reasons I need to bundle a WP7 app with compressed audio (mp3, wma etc). How do I play these freely/simultaneously?
The XNA framework only supports WAV files, so unless there is a pure C# managed code library somewhere to decompress mp3/wma/ogg (?) on the fly, the next option would be...
MediaElement. But I don't get good results with MediaElement. It seems that you need to add a MediaElement specifically as a tag in the xaml, and you can't use several instances (several tags). As soon as I play a certain MediaElement I can't play another MediaElement on the same page. I don't find anything about a restriction in the reference (the reference is very empty). I also tried dynamically creating MediaElement objects, but that doesn't seem valid at all, or I just cannot get it to play the files at all.
Use the built-in XNA content pipeline sound effect compression!
The default setting for a SoundEffect
content type is "Best" compression quality (which appears to, in fact, be no compression at all). Set the compression quality to "Low" and you will get a much, much smaller file. Or "Medium" for a nice balance between size and quality.
To change this setting, select your .wav
file in the solution explorer, press F4 to bring up the properties window, expand the "Content Processor" node, and change the compression quality setting that appears.
Here are instructions with screenshots:
Create a new WP7 XNA game project (or otherwise get an XNA Content Project)
Add a wav
file to the content project:
Press F4 with the wav
file selected in the Solution Explorer to bring up the properties window.
Expand the "Content Processor" node and change the compression quality to the desired setting.
A setting of "Best" gives no compression (raw waveform), settings of "Medium" and "Low" give a much smaller file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With