Cleanup, .smp is reimplemented, and will now show in .lq too
This commit is contained in:
parent
9f3c04c93e
commit
3c9b68e739
@ -246,6 +246,9 @@ namespace NadekoBot.Modules.Music
|
|||||||
var add = "";
|
var add = "";
|
||||||
if (mp.Stopped)
|
if (mp.Stopped)
|
||||||
add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n";
|
add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n";
|
||||||
|
var mps = mp.MaxPlaytimeSeconds;
|
||||||
|
if (mps > 0)
|
||||||
|
add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("g"))) + "\n";
|
||||||
if (mp.RepeatCurrentSong)
|
if (mp.RepeatCurrentSong)
|
||||||
add += "🔂 " + GetText("repeating_cur_song") + "\n";
|
add += "🔂 " + GetText("repeating_cur_song") + "\n";
|
||||||
else if (mp.Shuffle)
|
else if (mp.Shuffle)
|
||||||
@ -259,7 +262,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(add))
|
if (!string.IsNullOrWhiteSpace(add))
|
||||||
desc += add + "\n";
|
desc = add + "\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))
|
||||||
@ -795,23 +798,20 @@ namespace NadekoBot.Modules.Music
|
|||||||
await ReplyConfirmLocalized("max_queue_x", size).ConfigureAwait(false);
|
await ReplyConfirmLocalized("max_queue_x", size).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
//[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
//public async Task SetMaxPlaytime(uint seconds)
|
public async Task SetMaxPlaytime(uint seconds)
|
||||||
//{
|
{
|
||||||
// if (seconds < 15 && seconds != 0)
|
if (seconds < 15 && seconds != 0)
|
||||||
// return;
|
return;
|
||||||
|
|
||||||
// var channel = (ITextChannel)Context.Channel;
|
var mp = await _music.GetOrCreatePlayer(Context);
|
||||||
// MusicPlayer musicPlayer;
|
mp.MaxPlaytimeSeconds = seconds;
|
||||||
// if ((musicPlayer = _music.GetPlayer(Context.Guild.Id)) == null)
|
if (seconds == 0)
|
||||||
// return;
|
await ReplyConfirmLocalized("max_playtime_none").ConfigureAwait(false);
|
||||||
// musicPlayer.MaxPlaytimeSeconds = seconds;
|
else
|
||||||
// if (seconds == 0)
|
await ReplyConfirmLocalized("max_playtime_set", seconds).ConfigureAwait(false);
|
||||||
// await ReplyConfirmLocalized("max_playtime_none").ConfigureAwait(false);
|
}
|
||||||
// else
|
|
||||||
// await ReplyConfirmLocalized("max_playtime_set", seconds).ConfigureAwait(false);
|
|
||||||
//}
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
|
@ -1198,7 +1198,7 @@
|
|||||||
<value>`{0}drawnew` or `{0}drawnew 5`</value>
|
<value>`{0}drawnew` or `{0}drawnew 5`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="shuffleplaylist_cmd" xml:space="preserve">
|
<data name="shuffleplaylist_cmd" xml:space="preserve">
|
||||||
<value>playlistshuffle plsh</value>
|
<value>shuffle plsh</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="shuffleplaylist_desc" xml:space="preserve">
|
<data name="shuffleplaylist_desc" xml:space="preserve">
|
||||||
<value>Shuffles the current playlist.</value>
|
<value>Shuffles the current playlist.</value>
|
||||||
|
@ -50,6 +50,13 @@ namespace NadekoBot.Services.Music
|
|||||||
get => Queue.MaxQueueSize;
|
get => Queue.MaxQueueSize;
|
||||||
set => Queue.MaxQueueSize = value;
|
set => Queue.MaxQueueSize = value;
|
||||||
}
|
}
|
||||||
|
public uint MaxPlaytimeSeconds { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
const int _frameBytes = 3840;
|
||||||
|
const float _miliseconds = 20.0f;
|
||||||
|
public TimeSpan CurrentTime => TimeSpan.FromSeconds(_bytesSent / (float)_frameBytes / (1000 / _miliseconds));
|
||||||
|
private int _bytesSent = 0;
|
||||||
|
|
||||||
private IAudioClient _audioClient;
|
private IAudioClient _audioClient;
|
||||||
private readonly object locker = new object();
|
private readonly object locker = new object();
|
||||||
@ -78,6 +85,7 @@ namespace NadekoBot.Services.Music
|
|||||||
{
|
{
|
||||||
while (!Exited)
|
while (!Exited)
|
||||||
{
|
{
|
||||||
|
_bytesSent = 0;
|
||||||
CancellationToken cancelToken;
|
CancellationToken cancelToken;
|
||||||
(int Index, SongInfo Song) data;
|
(int Index, SongInfo Song) data;
|
||||||
lock (locker)
|
lock (locker)
|
||||||
@ -122,12 +130,14 @@ namespace NadekoBot.Services.Music
|
|||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while ((bytesRead = await b.ReadAsync(buffer, 0, buffer.Length, cancelToken).ConfigureAwait(false)) > 0)
|
while ((bytesRead = await b.ReadAsync(buffer, 0, buffer.Length, cancelToken).ConfigureAwait(false)) > 0
|
||||||
|
&& (MaxPlaytimeSeconds <= 0 || MaxPlaytimeSeconds >= CurrentTime.TotalSeconds))
|
||||||
{
|
{
|
||||||
var vol = Volume;
|
var vol = Volume;
|
||||||
if (vol != 1)
|
if (vol != 1)
|
||||||
AdjustVolume(buffer, vol);
|
AdjustVolume(buffer, vol);
|
||||||
await pcm.WriteAsync(buffer, 0, bytesRead, cancelToken).ConfigureAwait(false);
|
await pcm.WriteAsync(buffer, 0, bytesRead, cancelToken).ConfigureAwait(false);
|
||||||
|
unchecked { _bytesSent += bytesRead; }
|
||||||
|
|
||||||
await (pauseTaskSource?.Task ?? Task.CompletedTask);
|
await (pauseTaskSource?.Task ?? Task.CompletedTask);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ Check the guides for your platform on how to setup ffmpeg correctly:
|
|||||||
Linux Guide: https://goo.gl/ShjCUo");
|
Linux Guide: https://goo.gl/ShjCUo");
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException) { }
|
catch (OperationCanceledException) { }
|
||||||
|
catch (InvalidOperationException) { } // when ffmpeg is disposed
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_log.Info(ex);
|
_log.Info(ex);
|
||||||
|
@ -455,6 +455,7 @@
|
|||||||
"music_songs_shuffle_disable": "Songs will no longer shuffle.",
|
"music_songs_shuffle_disable": "Songs will no longer shuffle.",
|
||||||
"music_song_moved": "Song moved",
|
"music_song_moved": "Song moved",
|
||||||
"music_song_not_found": "No song found.",
|
"music_song_not_found": "No song found.",
|
||||||
|
"music_song_skips_after": "Songs will skip after {0}",
|
||||||
"music_time_format": "{0}h {1}m {2}s",
|
"music_time_format": "{0}h {1}m {2}s",
|
||||||
"music_to_position": "To position",
|
"music_to_position": "To position",
|
||||||
"music_unlimited": "unlimited",
|
"music_unlimited": "unlimited",
|
||||||
|
Loading…
Reference in New Issue
Block a user