I am using the MediaFoundationReader to play almost every format with my program, but I also read you are able to play streams using this. How would you go about reading streams from the internet using MediaFoundationReader?
When I initialize the MediaFoundationReader-object with an URL I get the following exception:
System.Runtime.InteropServices.COMException (0xC00D001A): Exception from HRESULT: 0xC00D001A
at NAudio.MediaFoundation.MediaFoundationInterop.MFCreateSourceReaderFromURL(String pwszURL, IMFAttributes pAttributes, IMFSourceReader& ppSourceReader)
at NAudio.Wave.MediaFoundationReader.CreateReader(MediaFoundationReaderSettings settings)
at NAudio.Wave.MediaFoundationReader..ctor(String file, MediaFoundationReaderSettings settings)
at NAudio.Wave.MediaFoundationReader..ctor(String file)
The URL, by the way is valid and works when I try it on my web-browser.
The error you are getting is: NS_E_FILE_NOT_FOUND "The system cannot find the file specified." So check your URL is correctly formatted.
Here's a quick snippet playing audio from a URL with MediaFoundationReader:
var url = "http://media.ch9.ms/ch9/2876/fd36ef30-cfd2-4558-8412-3cf7a0852876/AzureWebJobs103.mp3";
using(var mf = new MediaFoundationReader(url))
using(var wo = new WaveOutEvent())
{
wo.Init(mf);
wo.Play();
while (wo.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(1000);
}
}
User contributions licensed under CC BY-SA 3.0