/// <summary>
 /// Initializes a new instance of the <see cref="AudioComponent" /> class.
 /// </summary>
 /// <param name="robot">The robot.</param>
 internal AudioComponent(Robot robot) : base(robot)
 {
     this.audioFeed = new AsyncEventLoop <AudioFeedResponse>(
         (token) => robot.StartStream(client => client.AudioFeed(new AudioFeedRequest(), cancellationToken: token)),
         (response) => AudioReceived?.Invoke(this, new AudioReceivedEventArgs(response)),
         () => OnPropertyChanged(nameof(IsAudioFeedActive)),
         robot.PropagateException
         );
     this.playbackFeed = new AsyncDuplexEventLoop <ExternalAudioStreamRequest, ExternalAudioStreamResponse>(
         (token) => Robot.StartStream(client => client.ExternalAudioStreamPlayback(cancellationToken: token)),
         ProcessAudioResponse,
         () => { OnPropertyChanged(nameof(IsPlaybackActive)); playbackResult?.SetResult(PlaybackResult.Completed); },
         Robot.PropagateException
         );
 }
Esempio n. 2
0
 protected virtual void OnAudioReceived(AudioReceivedEventArgs e)
 {
     AudioReceived?.Invoke(this, e);
 }