Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
0
 /// <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());
 }
Exemplo n.º 3
0
 /// <summary>
 /// Disposes the <see cref="AudioPlayer"/> object.
 /// </summary>
 public void Dispose()
 {
     this.Stop();
     this.audioRenderDevice.Dispose();
     this.audioRenderDevice = null;
 }