Wednesday, January 12, 2011

Embedding a Sound File in Windows Phone 7 app (Silverlight)

Normally, I wouldn’t blog something that seems obvious, but it took me hours to figure this out and I always try to write blog posts for stuff that it took me a long time to figure out. Enormous props to Walt Ritscher (Twitter: @walktritscher) who helped me figure this out.
This blog post is for you if you have a sound file and you want it to:
be included with the application when the user downloads the app
play no matter what… even if the user is listening to music
First, grab the audio you want to add to the application and, if it’s not already a .wav file, make it so. If you’re just trying this out for kicks (or for the learning experience), download this files.
Coyote.wav
When prepping your audio, keep in mind if you want the user to hear it over their music. If so, make sure it is LOUD. I spent almost an hour thinking this method didn’t work because I couldn’t hear the sound over my music.
Next, create a directory in your Windows Phone 7 project and add your audio file like so: