/// <summary> /// Close and release all resources of the media. /// </summary> public void Close() { // If the stream was created internally. if (_isInternalStream) { // Dispose managed resources. if (_mediaStream != null) { _mediaStream.Dispose(); } } // Cleanup if (_binaryReader != null) { _binaryReader.Dispose(); } // Cleanup if (_audioPlayer != null) { _audioPlayer.Dispose(); } if (_isInternalStream) { _mediaStream = null; } _binaryReader = null; _audioPlayer = null; }
/// <summary> /// /// </summary> /// <param name="mediaStream"></param> public void Open(Stream mediaStream) { _isInternalStream = false; _mediaStream = mediaStream; // Create the binary reader. _binaryReader = new BinaryReader(_mediaStream); _mux = new VideoAudioMux(_binaryReader); // Create the audio player. _device = Nequeo.IO.Audio.Devices.GetDevice(0); _audioPlayer = new IO.Audio.WavePlayer(_device); }
/// <summary> /// /// </summary> /// <param name="mediaFilename"></param> public void Open(string mediaFilename) { _isInternalStream = true; // Create the binary reader. _mediaStream = new FileStream(mediaFilename, FileMode.Open, FileAccess.Read); _binaryReader = new BinaryReader(_mediaStream); _mux = new VideoAudioMux(_binaryReader); // Create the audio player. _device = Nequeo.IO.Audio.Devices.GetDevice(0); _audioPlayer = new IO.Audio.WavePlayer(_device); }
/// <summary> /// Dispose(bool disposing) executes in two distinct scenarios. /// If disposing equals true, the method has been called directly /// or indirectly by a user's code. Managed and unmanaged resources /// can be disposed. /// If disposing equals false, the method has been called by the /// runtime from inside the finalizer and you should not reference /// other objects. Only unmanaged resources can be disposed. /// </summary> protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this._disposed) { // Note disposing has been done. _disposed = true; // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // If the stream was created internally. if (_isInternalStream) { // Dispose managed resources. if (_mediaStream != null) { _mediaStream.Dispose(); } } if (_binaryReader != null) { _binaryReader.Dispose(); } if (_audioPlayer != null) { _audioPlayer.Dispose(); } } // Call the appropriate methods to clean up // unmanaged resources here. // If the stream was created internally. if (_isInternalStream) { _mediaStream = null; } _binaryReader = null; _audioPlayer = null; } }