How to play MP3 stream in C #

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);
                    }
                }
            }
+3
source share
2 answers

http://www.un4seen.com/

bass.dll.NET api

I know this is not an answer to your code, but its a good music library

+1
source

, MP3, NAudio. , , MP3-, BufferedWaveProvider. BufferedWaveProvider .

+1

Source: https://habr.com/ru/post/1795598/


All Articles