I have this url : https://verses.quran.com/Shuraym/ogg/067001.ogg
I need to play this audio on my c# WPF app without having to download it.
I've been using this for url with an mp3 file extension :
// this code use NAudio
using (var mf = new MediaFoundationReader(url))
using (var wo = new WasapiOut())
{
wo.Init(mf);
wo.Play();
PlayingAudioWasapiOut.Add(wo);
while (wo.PlaybackState == PlaybackState.Playing)
{
await Task.Delay(1000);
};
}
I tried the code that works for the mp3 url, but it does not work with an ogg url (it just exit the method without any error at the line 1). I also tried using this :
using (var vorbisStream = new NAudio.Vorbis.VorbisWaveReader(url))
using (var waveOut = new NAudio.Wave.WaveOutEvent())
{
waveOut.Init(vorbisStream);
waveOut.Play();
PlayingAudioWaveOutEvent.Add(waveOut);
while (waveOut.PlaybackState == PlaybackState.Playing)
{
await Task.Delay(1000);
}
}
But it did not work because it is made for local file audio.
I made it