From 3e65fcf47b116122e10704a26d36ef79c5093c89 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Mon, 9 Apr 2018 19:17:03 +0200 Subject: Play Audio async --- DiscoBot/Commands/Voice.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'DiscoBot/Commands/Voice.cs') diff --git a/DiscoBot/Commands/Voice.cs b/DiscoBot/Commands/Voice.cs index 7b28965..7ffb029 100644 --- a/DiscoBot/Commands/Voice.cs +++ b/DiscoBot/Commands/Voice.cs @@ -30,6 +30,7 @@ var discord = Client.CreatePCMStream(AudioApplication.Music); await output.CopyToAsync(discord); + await discord.FlushAsync(); } @@ -65,11 +66,11 @@ } [Command("play")] - public Task PlayAudioAsync(string path) + public async Task PlayAudioAsync(string path) { if (Client == null) { - return this.Context.Channel.SendMessageAsync("Erst Joinen!"); + await this.Context.Channel.SendMessageAsync("Erst Joinen!"); } var sounds = Enum.GetValues(typeof(Sound)); @@ -85,10 +86,10 @@ if (sc.Compare(path, tSound.ToString()) > SpellCorrect.ErrorThreshold) { - return SendAsync(path); + await Task.Run(() => Voice.SendAsync(path)); } - return SoundEffects.Play(tSound); + await Task.Run(() => SoundEffects.Play(tSound)); } private static Process CreateStream(string path, int vol = 256) -- cgit v1.2.3-70-g09d2