public Task PlayAudioAsync(DialogAudioOutputStream stream) { this.IsPlaying = true; return(new Task(async() => { await Task.Delay(PlayLength); this.OutputEnded.Invoke(); })); }
public void EnqueueDialogAudio(DialogAudioOutputStream audioData) { this.IsPlaying = true; Task.Run(async() => { await Task.Delay(PlayLength); this.OutputEnded.Invoke(); }); }
/// <summary> /// Initializes a new instance of the <see cref="DialogResponse"/> class. /// </summary> /// <param name="messageBody"> The body of the dialog response. </param> /// <param name="messageMedia"> Optional media associated with the dialog response. </param> /// <param name="shouldEndTurn"> Whether the response indicates the turn should end. </param> /// <param name="shouldStartNewTurn"> Whether the response indicates a new turn should follow. </param> public DialogResponse( object messageBody, DialogAudioOutputStream messageMedia, bool shouldEndTurn, bool shouldStartNewTurn) { this.MessageBody = messageBody; this.MessageMedia = messageMedia; this.TurnEndIndicated = shouldEndTurn; this.FollowupTurnIndicated = shouldStartNewTurn; }
/// <summary> /// Initializes a new instance of the <see cref="DialogAudioOutputMediaSource"/> class. /// </summary> /// <param name="stream"> The DialogAudioOutputStream to use as input for this MediaElement. </param> public DialogAudioOutputMediaSource(DialogAudioOutputStream stream) { Contract.Requires(stream != null); this.sourceStream = stream; // Here we precompute constants for the duration of this source to avoid doing it every sample var encoding = stream.Format.Encoding; this.sampleDuration = SampleDurationForEncoding(encoding); var bytesInSample = (uint)(this.sampleDuration.TotalSeconds * encoding.Bitrate / 8); var sourceDescriptor = new AudioStreamDescriptor(stream.Format.Encoding); var mediaStreamSource = new MediaStreamSource(sourceDescriptor) { IsLive = true, BufferTime = TimeToBuffer, }; mediaStreamSource.SampleRequested += this.OnMediaSampleRequested; this.WindowsMediaSource = MediaSource.CreateFromIMediaSource(mediaStreamSource); }