MediaFoundationReader Error with AIFF file

Mar 9 at 6:42 PM
Hi Guys,
First, cudos to Mark H and the other contributors who did the MediaFoundationReader development. Nice job. And with the addition of HTTPS support, it's making the .Net MediaPlayer look very lame by comparison.


I'm getting the error below on AIFF files. The test file plays fine with standard .Net MediaPlayer class. But MediaFoundationReader blows up. And the same exact code path works fine with Mp3, Wma, and Wav files.
  • Has anyone successfully tested AIFF with MediaFoundationReader ?
error message: The byte stream type of the given URL is unsupported. (Exception from HRESULT: 0xC00D36C4) 
stack trace
   at NAudio.MediaFoundation.MediaFoundationInterop.MFCreateSourceReaderFromURL(String pwszURL, IMFAttributes pAttributes, IMFSourceReader& ppSourceReader)
   at NAudio.Wave.MediaFoundationReader.CreateReader(MediaFoundationReaderSettings settings)
   at NAudio.Wave.MediaFoundationReader.Init(MediaFoundationReaderSettings initialSettings)
   at NAudio.Wave.MediaFoundationReader..ctor(String file)
   at Breakthru.DXSound.SecondaryBufferNA.CreateInputStream(String fileName) in C:\1-DEV\CS2015\SoundDX\SoundDX\SecondaryBufferNA.cs:line 438
   at Breakthru.DXSound.SecondaryBufferNA.CreateAndInitializeSoundBuffer() in C:\1-DEV\CS2015\SoundDX\SoundDX\SecondaryBufferNA.cs:line 318
My code looks essentially like this:
        WaveOut waveOutDevice = new WaveOut()
                {
                    DesiredLatency = 100,
                    NumberOfBuffers = 2,
                };
        WaveChannel32 inputStream = null;
                WaveStream mediaFileReader;
                mediaFileReader = new MediaFoundationReader(fileName); 
                inputStream = new WaveChannel32(mediaFileReader);
                waveOutDevice.Init(inputStream);  <== program gets above exception on this call
                
Mar 10 at 8:50 AM
NAudio contains an AiffFileReader class, which you can use alternatively
Mar 10 at 10:51 AM
Hi Freefall, thanks for the reply.
Yeah, I get the same error from the AiffFileReader. So maybe it's something weird about the Aiff file I'm testing with. Or maybe the Klite codec package configuration on my system is blocking aiffs.
Mar 14 at 4:40 PM
Then I assume it´s probably some kind of corrupt or experimental aiff file