diff --git a/src/NadekoBot/Services/Music/MusicPlayer.cs b/src/NadekoBot/Services/Music/MusicPlayer.cs index 156e0801..49f2c99d 100644 --- a/src/NadekoBot/Services/Music/MusicPlayer.cs +++ b/src/NadekoBot/Services/Music/MusicPlayer.cs @@ -113,6 +113,8 @@ namespace NadekoBot.Services.Music private bool newVoiceChannel = false; private readonly IGoogleApiService _google; + private bool cancel = false; + private ConcurrentHashSet RecentlyPlayedUsers { get; } = new ConcurrentHashSet(); public TimeSpan TotalPlaytime { @@ -148,6 +150,7 @@ namespace NadekoBot.Services.Music while (!Exited) { _bytesSent = 0; + cancel = false; CancellationToken cancelToken; (int Index, SongInfo Song) data; lock (locker) @@ -210,6 +213,7 @@ namespace NadekoBot.Services.Music catch (OperationCanceledException) { _log.Info("Song Canceled"); + cancel = true; } catch (Exception ex) { @@ -230,6 +234,13 @@ namespace NadekoBot.Services.Music } OnCompleted?.Invoke(this, data.Song); + + if (_bytesSent == 0 && !cancel) + { + lock (locker) + Queue.RemoveSong(data.Song); + _log.Info("Song removed because it can't play"); + } } } try @@ -319,7 +330,6 @@ namespace NadekoBot.Services.Music } do { - _log.Info("Waiting for something to happen"); await Task.Delay(500); } while ((Queue.Count == 0 || Stopped) && !Exited); diff --git a/src/NadekoBot/Services/Music/MusicQueue.cs b/src/NadekoBot/Services/Music/MusicQueue.cs index c8890484..50135b72 100644 --- a/src/NadekoBot/Services/Music/MusicQueue.cs +++ b/src/NadekoBot/Services/Music/MusicQueue.cs @@ -163,5 +163,13 @@ namespace NadekoBot.Services.Music return s; } } + + public void RemoveSong(SongInfo song) + { + lock (locker) + { + Songs.Remove(song); + } + } } }