Live stream audio files using NAudio and Vorbis

442 Views Asked by At

I have access to files that contain audio streams in ogg format. They are continuous and are played in our html files using an audio tag:

     <div style="display: none;">
        <audio controls="controls" preload="none" autoplay><source src="http://rock.blahblah.com/stream" type="application/ogg"></source></audio>
    </div>

I am using Naudio with the Vorbis addition. The code to run the stream is :

 Stream aStream = WebRequest.Create("http://rock.blahblah.com/stream").GetResponse().GetResponseStream();
 var vorbis = new NAudio.Vorbis.VorbisWaveReader(aStream);
 var waveOut = new NAudio.Wave.WaveOut();
 waveOut.Init(vorbis);
 waveOut.Play();

This throws a "This stream does not support seek operations" exception. Which makes sense because I am reading from a stream that does not have a well-defined end or length.

Any idea how to play continous ogg streams using the Vorbis plugin?

Thanks

1

There are 1 best solutions below

0
bryanforst On

Partial answer as its not an nAudio solution. We are using VLC.DotNet.WPF in the app and their player can stream the uri just fine.