views:

2960

answers:

3

Has to be free.

+5  A: 

Use the MediaElement control.

This page seems to give a pretty in depth explanation: http://blogs.vbcity.com/xtab/archive/2008/06/10/9091.aspx

Spencer Ruport
I don't suppose you know how to get it to load the mp3 from a Resource in the assembly? I don't like having to have external resource files.
chaiguy
Or some way to load it from a stream, because I can get a stream for the resource manually.
chaiguy
+1  A: 

Though I didn't actually mention it, I was hoping to find a way to play embedded MP3 resources, and neither MediaPlayer nor MediaElement support loading from streams (they accept a uri, but don't work with pack:// uris).

I ended up simply extracting the embedded MP3 to a temporary directory, playing it (with MediaPlayer), then deleting it when done. It involves a slight delay (of about 0.5-1 second) but seems to be the safest way to play an embedded resource.

chaiguy
+1  A: 

Check out my blog post on using NAudio to replace the audio playback mechanism in babysmash. It explains how to play MP3 files directly from embedded resources without the need to save to a temporary file.

Mark Heath
Super, I will check that out, thanks.
chaiguy