I want to play an MP3 stream in my C # application. I have a server application that captures wave sound and converts it to MP3, and then writes it to a network stream. The client then reads this stream to play MP3. I tried NAudio with the following code example, but this throws an exception:
using (WaveStream blockAlignedStream =
new BlockAlignReductionStream(
WaveFormatConversionStream.CreatePcmStream(
new Mp3FileReader(ms))))
{
using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
{
waveOut.Init(blockAlignedStream);
waveOut.Play();
while (waveOut.PlaybackState == PlaybackState.Playing )
{
System.Threading.Thread.Sleep(100);
}
}
}
source
share