MediaFoundationReader reader = new MediaFoundationReader(videoPath);
BufferedWaveProvider bufferedWaveProvider = new BufferedWaveProvider(reader.WaveFormat);
bufferedWaveProvider.BufferDuration = TimeSpan.FromMilliseconds(audioBufferLengh * 4);
bufferedWaveProvider.DiscardOnBufferOverflow = true;
bufferedWaveProvider.ReadFully = true;
WaveOut player = new WaveOut();
player.Init(bufferedWaveProvider);
player.Play();
the exception:
Excepcion no controlada: System.Runtime.InteropServices.COMException: No se encontro ninguna transformacion adecuada para codificar o descodificar el contenido. (Excepcion de HRESULT: 0xC00D5212)
en NAudio.MediaFoundation.IMFSourceReader.SetCurrentMediaType(Int32 dwStreamIndex, IntPtr pdwReserved, IMFMediaType pMediaType)
en NAudio.Wave.MediaFoundationReader.CreateReader(MediaFoundationReaderSettings settings)
en NAudio.Wave.MediaFoundationReader.Init(MediaFoundationReaderSettings initialSettings)
en NAudio.Wave.MediaFoundationReader..ctor(String file)
en AsciiPlayer.Program.Main(String[] arg) en AsciiPlayer\Program.cs:linea 160
MediaFoundationReader relies on the codecs installed in Windows, so if your version of Windows can't play the file in Windows Media Player then its likely that MediaFoundationPlayer also won't be able to play it
My code
the exception:
the video:
https://github.com/naudio/NAudio/assets/68958481/4f273ff5-9576-4693-a44b-86b17ed998fe