I was asked in a comment how to play a sound from a stream, from an embedded resource in Silverlight or WPF.
My answer is that I wouldn’t use an embedded resource, instead I’d suggest using the “Content” Build Action as shown below:
I’ve set the explosion.mp3 file’s Build Action to “Content”. Then, using my audio playing technique, I call the function:
PlayAudio("/explosion.mp3", .5);
(The .5 sets the volume.)
You might look at MediaStreamSource (set via the MediaElement’s SetSource property).
There’s an example dealing with MP3 files here. Realize that path requires that your code fully take over the the responsibility for streaming — including understanding the low-level details of the audio/video format. For example, you would need to know how to decode an MP3 file.
[…] I used a few of the same tricks I’ve used before. […]
Hey, your brief article was what finally got my silverlight app playing.
The article at http://blogs.msdn.com/katriend/archive/2008/04/27/different-ways-for-loading-images-and-files-in-silverlight-2-applications.aspx may help your reader out with embedding content as a resource.