(Re)added shuffle, rpl, rcs and autoplay to the top of the .lq

This commit is contained in:
Master Kwoth 2017-07-02 15:44:00 +02:00
parent 8e1c20624d
commit 45e4816033
3 changed files with 27 additions and 13 deletions

View File

@ -227,10 +227,18 @@ namespace NadekoBot.Modules.Music
desc = $"`🔊` {songs[current].PrettyFullName}\n\n" + desc; desc = $"`🔊` {songs[current].PrettyFullName}\n\n" + desc;
if (mp.RepeatCurrentSong) if (mp.RepeatCurrentSong)
desc = "🔂 " + GetText("repeating_cur_song") + "\n\n" + desc; desc = "🔂 " + GetText("repeating_cur_song") + "\n\n" + desc;
else if (mp.Shuffle) else if (mp.Shuffle)
desc = "🔀 " + GetText("shuffling_playlist") + "\n\n" + desc; desc = "🔀 " + GetText("shuffling_playlist") + "\n\n" + desc;
else
{
if(mp.Autoplay)
desc = "↪ " + GetText("autoplaying") + "\n\n" + desc;
if (mp.RepeatPlaylist)
desc = "🔁 " + GetText("repeating_playlist") + "\n\n" + desc;
}
var embed = new EmbedBuilder() var embed = new EmbedBuilder()
.WithAuthor(eab => eab.WithName(GetText("player_queue", curPage + 1, lastPage + 1)) .WithAuthor(eab => eab.WithName(GetText("player_queue", curPage + 1, lastPage + 1))
@ -798,7 +806,6 @@ namespace NadekoBot.Modules.Music
// await ReplyConfirmLocalized("max_playtime_set", seconds).ConfigureAwait(false); // await ReplyConfirmLocalized("max_playtime_set", seconds).ConfigureAwait(false);
//} //}
//todo test rcs
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ReptCurSong() public async Task ReptCurSong()
@ -820,7 +827,6 @@ namespace NadekoBot.Modules.Music
.ConfigureAwait(false); .ConfigureAwait(false);
} }
//todo test rpl
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RepeatPl() public async Task RepeatPl()

View File

@ -61,6 +61,9 @@ namespace NadekoBot.Services.Music
public event Action<MusicPlayer, bool> OnPauseChanged; public event Action<MusicPlayer, bool> OnPauseChanged;
#endregion #endregion
private bool manualSkip = false;
public MusicPlayer(MusicService musicService, IVoiceChannel vch, ITextChannel output, float volume) public MusicPlayer(MusicService musicService, IVoiceChannel vch, ITextChannel output, float volume)
{ {
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
@ -80,6 +83,7 @@ namespace NadekoBot.Services.Music
{ {
data = Queue.Current; data = Queue.Current;
cancelToken = SongCancelSource.Token; cancelToken = SongCancelSource.Token;
manualSkip = false;
} }
try try
{ {
@ -142,12 +146,10 @@ namespace NadekoBot.Services.Music
} }
finally finally
{ {
do //if repeating current song, just ignore other settings,
{ // and play this song again (don't change the index)
await Task.Delay(500); // ignore rcs if song is manually skipped
} if (!RepeatCurrentSong || manualSkip)
while (Stopped && !Exited);
if (!RepeatCurrentSong) //if repeating current song, just ignore other settings, and play this song again (don't change the index)
{ {
if (Shuffle) if (Shuffle)
{ {
@ -172,9 +174,8 @@ namespace NadekoBot.Services.Music
_log.Info("Loading related song failed."); _log.Info("Loading related song failed.");
} }
} }
else if (Queue.Count == data.Index && !RepeatPlaylist) else if (Queue.Count - 1 == data.Index && !RepeatPlaylist && !manualSkip)
{ {
//todo test repeatplaylist
_log.Info("Stopping because repeatplaylist is disabled"); _log.Info("Stopping because repeatplaylist is disabled");
Stop(); Stop();
} }
@ -185,6 +186,11 @@ namespace NadekoBot.Services.Music
} }
} }
} }
do
{
await Task.Delay(500);
}
while (Stopped && !Exited);
} }
} }
}, SongCancelSource.Token); }, SongCancelSource.Token);
@ -221,10 +227,11 @@ namespace NadekoBot.Services.Music
return (true, Queue.Count); return (true, Queue.Count);
} }
public void Next(int skipCount) public void Next(int skipCount = 1)
{ {
lock (locker) lock (locker)
{ {
manualSkip = true;
Queue.Next(skipCount - 1); Queue.Next(skipCount - 1);
Stopped = false; Stopped = false;
Unpause(); Unpause();

View File

@ -404,6 +404,7 @@
"music_attempting_to_queue": "Attempting to queue {0} songs...", "music_attempting_to_queue": "Attempting to queue {0} songs...",
"music_autoplay_disabled": "Autoplay disabled.", "music_autoplay_disabled": "Autoplay disabled.",
"music_autoplay_enabled": "Autoplay enabled.", "music_autoplay_enabled": "Autoplay enabled.",
"music_autoplaying": "Auto-playing.",
"music_defvol_set": "Default volume set to {0}%", "music_defvol_set": "Default volume set to {0}%",
"music_dir_queue_complete": "Directory queue complete.", "music_dir_queue_complete": "Directory queue complete.",
"music_fairplay": "fairplay", "music_fairplay": "fairplay",