public async void PlayMusicAsync() { Process ffmpeg = null; AudioStream pcm = null; while (true) { if (PlayList.Count > 0) { await GetAudioClient(); if (audioClient == null) { Console.WriteLine("[ERROR]"); await Task.Delay(900); } else { ffmpeg = CreateStreamAudio(await PlayList.Peek().Uri()); pcm = audioClient.CreatePCMStream(AudioApplication.Music); try { await ffmpeg.StandardOutput.BaseStream.CopyToAsync(pcm); } finally { await pcm.FlushAsync(); } } PlayList.Dequeue(); } } }
public override async Task FlushAsync(CancellationToken cancelToken) { await _next.FlushAsync(cancelToken).ConfigureAwait(false); }