Fix ReadableDuration
how also did I forget about SeekCommandAsync Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
db55ca7fb1
commit
457c5ce744
2 changed files with 7 additions and 5 deletions
|
@ -149,15 +149,17 @@ public sealed class ControlsCommandGroup(
|
||||||
feedbackService.Theme.FaultOrDanger);
|
feedbackService.Theme.FaultOrDanger);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.CurrentTrack is null)
|
var track = player.CurrentTrack;
|
||||||
|
|
||||||
|
var trackDuration = track.Duration;
|
||||||
|
if (position > trackDuration)
|
||||||
{
|
{
|
||||||
return await feedbackService.SendContextualMessageResult(
|
return await feedbackService.SendContextualMessageResult(
|
||||||
"There's nothing playing right now.",
|
$"Selected position ({position.ReadableDuration()}) is greater than " +
|
||||||
|
$"track's duration ({trackDuration.ReadableDuration()})",
|
||||||
feedbackService.Theme.FaultOrDanger);
|
feedbackService.Theme.FaultOrDanger);
|
||||||
}
|
}
|
||||||
|
|
||||||
var track = player.CurrentTrack;
|
|
||||||
|
|
||||||
await player.SeekAsync(position);
|
await player.SeekAsync(position);
|
||||||
|
|
||||||
return await feedbackService.SendContextualMessageResult(
|
return await feedbackService.SendContextualMessageResult(
|
||||||
|
|
|
@ -4,6 +4,6 @@ public static class TimeSpanExtensions
|
||||||
{
|
{
|
||||||
public static string ReadableDuration(this TimeSpan duration)
|
public static string ReadableDuration(this TimeSpan duration)
|
||||||
{
|
{
|
||||||
return $"{duration.TotalMinutes:N0}:{duration.Seconds:00}";
|
return $"{Math.Truncate(duration.TotalMinutes)}:{duration.Seconds:00}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue