[.net] Playing MP3s with DirectSound

Started by
3 comments, last by trevaaar 18 years, 10 months ago
Is there a way to get DirectSound to play mp3s? Thanks. -Nick
Advertisement
frankly, no.

From the MSDN site: 'DirectSound does not support compressed WAV formats.'
You can decompress the encoded files using Win32's multimedia functions of the Audio Compression Manager. Unfortunately, there is no freely available .NET wrapper for these, and dealing the functions is frankly a bit of a pain. However, it's mostly due to poor documentation and strange design rather than any inherent difficulty, so if you put in a little bit of time, it should be easy to figure out. From there, pumping the decoded PCM data into a DirectSound buffer is trivial.

Another much simpler alternative would be to just use the AudioVideoPlayback.Audio class.

Hope this helps point you in the right direction.

-bodisiw
-bodisiw
Thanks. I was planning on avoiding AudioVideoPlayback, but I guess I'll just use .wav files for sound effects and use mp3s for background music.
Well there is my Ogg Vorbis playback library for .NET that I plug shamelessly on here every time somebody asks a question like this... Ogg has better compression than MP3, and it's completely open source. The library I wrote could use some serious work though :(

This topic is closed to new replies.

Advertisement