Class MediaFoundationReader
Class for reading any file that Media Foundation can play Automatically converts to PCM If it is a video file with multiple audio streams, it will pick out the first audio stream
public class MediaFoundationReader : WaveStream, IAsyncDisposable, IDisposable, IWaveProvider
- Inheritance
-
MediaFoundationReader
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
MediaFoundationReader()
Default constructor
protected MediaFoundationReader()
MediaFoundationReader(string)
Creates a new MediaFoundationReader based on the supplied file
public MediaFoundationReader(string file)
Parameters
filestringFilename (can also be a URL e.g. http:// mms:// file://)
MediaFoundationReader(string, MediaFoundationReaderSettings)
Creates a new MediaFoundationReader based on the supplied file
public MediaFoundationReader(string file, MediaFoundationReader.MediaFoundationReaderSettings settings)
Parameters
filestringFilename
settingsMediaFoundationReader.MediaFoundationReaderSettingsAdvanced settings
Properties
Length
The bytesRequired of this stream in bytes (n.b may not be accurate)
public override long Length { get; }
Property Value
Position
Current position within this stream
public override long Position { get; set; }
Property Value
WaveFormat
WaveFormat of this stream (n.b. this is after converting to PCM)
public override WaveFormat WaveFormat { get; }
Property Value
Methods
Dispose(bool)
Cleans up after finishing with this reader
protected override void Dispose(bool disposing)
Parameters
disposingbooltrue if called from Dispose
Init(MediaFoundationReaderSettings)
Initializes
protected void Init(MediaFoundationReader.MediaFoundationReaderSettings initialSettings)
Parameters
initialSettingsMediaFoundationReader.MediaFoundationReaderSettings
Read(byte[], int, int)
Reads from this wave stream
public override int Read(byte[] buffer, int offset, int count)
Parameters
Returns
- int
Number of bytes read; 0 indicates end of stream
Read(Span<byte>)
Reads from this wave stream into a span (zero-copy path for WASAPI playback)
public override int Read(Span<byte> buffer)
Parameters
Returns
Events
WaveFormatChanged
WaveFormat has changed
public event EventHandler WaveFormatChanged