summaryrefslogtreecommitdiff
path: root/DiscoBot/Audio
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot/Audio')
-rw-r--r--DiscoBot/Audio/AudioModule.cs2
-rw-r--r--DiscoBot/Audio/AudioService.cs10
-rw-r--r--DiscoBot/Audio/Soundeffects.cs10
-rw-r--r--DiscoBot/Audio/Voice.cs11
4 files changed, 15 insertions, 18 deletions
diff --git a/DiscoBot/Audio/AudioModule.cs b/DiscoBot/Audio/AudioModule.cs
index 9cc4823..f2097b7 100644
--- a/DiscoBot/Audio/AudioModule.cs
+++ b/DiscoBot/Audio/AudioModule.cs
@@ -71,7 +71,7 @@ namespace DiscoBot.Audio
await _service.SendAudioAsync(Context.Guild, Context.Channel, song);
}
- await SoundEffects.Play(tSound);
+ SoundEffects.Play(tSound);
}
}
} \ No newline at end of file
diff --git a/DiscoBot/Audio/AudioService.cs b/DiscoBot/Audio/AudioService.cs
index 52caf23..6e01980 100644
--- a/DiscoBot/Audio/AudioService.cs
+++ b/DiscoBot/Audio/AudioService.cs
@@ -16,8 +16,7 @@
public async Task JoinAudio(IGuild guild, IVoiceChannel target)
{
- IAudioClient client;
- if (this.connectedChannels.TryGetValue(guild.Id, out client))
+ if (this.connectedChannels.TryGetValue(guild.Id, out var client))
{
return;
}
@@ -39,8 +38,7 @@
public async Task LeaveAudio(IGuild guild)
{
- IAudioClient client;
- if (this.connectedChannels.TryRemove(guild.Id, out client))
+ if (this.connectedChannels.TryRemove(guild.Id, out var client))
{
await client.StopAsync();
//await Log(LogSeverity.Info, $"Disconnected from voice on {guild.Name}.");
@@ -55,8 +53,8 @@
await channel.SendMessageAsync("File does not exist.");
return;
}
- IAudioClient client;
- if (this.connectedChannels.TryGetValue(guild.Id, out client))
+
+ if (this.connectedChannels.TryGetValue(guild.Id, out var client))
{
//await Log(LogSeverity.Debug, $"Starting playback of {path} in {guild.Name}");
using (var ffmpeg = this.CreateStream(path))
diff --git a/DiscoBot/Audio/Soundeffects.cs b/DiscoBot/Audio/Soundeffects.cs
index 7e5e918..1e6dda1 100644
--- a/DiscoBot/Audio/Soundeffects.cs
+++ b/DiscoBot/Audio/Soundeffects.cs
@@ -23,10 +23,10 @@
{
public static int Volume { get; set; } = 50;
- public static async Task Play(Sound s)
+ public static void Play(Sound s)
{
string url = string.Empty;
- int volume = 256;
+ int volume = 255;
switch (s)
{
case Sound.Bell:
@@ -35,7 +35,7 @@
break;
case Sound.Finish:
url = "https://www.myinstants.com/media/sounds/finishhim.swf.mp3";
- break;
+ break;
case Sound.Magic:
url = "https://www.myinstants.com/media/sounds/dream-harp-sound-effect.mp3";
break;
@@ -58,7 +58,7 @@
case Sound.Wrong:
url = "https://www.myinstants.com/media/sounds/wrong-answer-sound-effect.mp3";
volume = 50;
- break;
+ break;
}
volume = (int)(volume * (Volume / 100.0));
@@ -67,7 +67,7 @@
if (url != string.Empty)
{
// await Dsa.Service.SendAudioAsync(url, vol);
- Voice.SendAsync(url, volume);
+ Voice.Send(url, volume);
return;
}
diff --git a/DiscoBot/Audio/Voice.cs b/DiscoBot/Audio/Voice.cs
index 84a221c..2c8f75e 100644
--- a/DiscoBot/Audio/Voice.cs
+++ b/DiscoBot/Audio/Voice.cs
@@ -18,7 +18,7 @@
{
public static IAudioClient Client { get; set; }
- public static void SendAsync(string path, int volume = 256)
+ public static void Send(string path, int volume = 256)
{
if (Client == null)
{
@@ -26,7 +26,7 @@
}
// Create FFmpeg using the previous example
- var ffmpeg = CreateStream(path, volume);
+ var ffmpeg = CreateStream(path, volume);
var output = ffmpeg.StandardOutput.BaseStream;
var barInvoker = new BackgroundWorker();
barInvoker.DoWork += delegate
@@ -36,7 +36,7 @@
discord.FlushAsync();
};
-
+
barInvoker.RunWorkerAsync();
}
@@ -66,10 +66,9 @@
if (Client != null)
{
- var wait = SoundEffects.Play(Sound.Nooo);
+ SoundEffects.Play(Sound.Nooo);
await Client.StopAsync();
Client = null;
- wait.Wait();
}
}
@@ -103,7 +102,7 @@
if (sc.Compare(path, tSound.ToString()) > SpellCorrect.ErrorThreshold)
{
- await Task.Run(() => Voice.SendAsync(path));
+ await Task.Run(() => Voice.Send(path));
}
await Task.Run(() => SoundEffects.Play(tSound));