Search code examples
.netcompact-frameworkaudiomp3stream

playing a stream of PCM audio on .NET CF


I have a .NET CF library that produces PCM formatted data stream (as Stream object) from an MP3 file. I want to make my Windows Mobile phone to play the podcast I decode with that library. How can I play the PCM stream? I have tried PlaySound pinvoke stuff but does not work. It expects the entire song to be in memory as a WAVE file, which is not that good since just the compressed podcast is 30MB.

I was thinking of slicing the stream to chunks and appending the WAVE header to each chunk and playing one chunk after the other. But I did not succeed with that yet.


Solution

  • If you have .NET 3.5 then you could use the SoundPlayer component.

    From the MSDN:

    The SoundPlayer class provides a simple interface for loading and playing a .wav file. The SoundPlayer class supports loading a .wav file from a file path, a URL, a Stream that contains a .wav file, or an embedded resource that contains a .wav file.