/// <summary> /// Initializes a new instance of the <see cref="AudioPlayer"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> public AudioPlayer(Pipeline pipeline, AudioPlayerConfiguration configuration) : base(pipeline) { this.pipeline = pipeline; this.configuration = configuration; this.currentInputFormat = configuration.InputFormat; this.AudioLevelInput = pipeline.CreateReceiver <double>(this, this.SetAudioLevel, nameof(this.AudioLevelInput)); this.AudioLevel = pipeline.CreateEmitter <double>(this, nameof(this.AudioLevel)); this.audioRenderDevice = new AudioRenderer(); this.audioRenderDevice.Initialize(configuration.DeviceName); this.pipeline.PipelineCompletionEvent += this.OnPipelineCompletionEvent; if (configuration.AudioLevel >= 0) { this.audioRenderDevice.AudioLevel = configuration.AudioLevel; } }
/// <summary> /// Gets a list of available audio render devices. /// </summary> /// <returns> /// An array of available render device names. /// </returns> public static string[] GetAvailableDevices() { return(AudioRenderer.GetAvailableRenderDevices()); }
/// <summary> /// Disposes the <see cref="AudioPlayer"/> object. /// </summary> public void Dispose() { this.Stop(); this.audioRenderDevice.Dispose(); this.audioRenderDevice = null; }