(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;
if (mp.RepeatCurrentSong)
desc = "🔂 " + GetText("repeating_cur_song") + "\n\n" + desc;
else if (mp.Shuffle)
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()
.WithAuthor(eab => eab.WithName(GetText("player_queue", curPage + 1, lastPage + 1))
@ -797,8 +805,7 @@ namespace NadekoBot.Modules.Music
// else
// await ReplyConfirmLocalized("max_playtime_set", seconds).ConfigureAwait(false);
//}
//todo test rcs
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ReptCurSong()
@ -819,8 +826,7 @@ namespace NadekoBot.Modules.Music
await Context.Channel.SendConfirmAsync("🔂 " + GetText("repeating_track_stopped"))
.ConfigureAwait(false);
}
//todo test rpl
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task RepeatPl()

View File

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

View File

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