Fix ReadableDuration

how also did I forget about SeekCommandAsync

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2023-12-17 05:23:58 +03:00
parent db55ca7fb1
commit 457c5ce744
Signed by: mctaylors
GPG key ID: 7181BEBE676903C1
2 changed files with 7 additions and 5 deletions

View file

@ -149,15 +149,17 @@ public sealed class ControlsCommandGroup(
feedbackService.Theme.FaultOrDanger);
}
if (player.CurrentTrack is null)
var track = player.CurrentTrack;
var trackDuration = track.Duration;
if (position > trackDuration)
{
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);
}
var track = player.CurrentTrack;
await player.SeekAsync(position);
return await feedbackService.SendContextualMessageResult(

View file

@ -4,6 +4,6 @@ public static class TimeSpanExtensions
{
public static string ReadableDuration(this TimeSpan duration)
{
return $"{duration.TotalMinutes:N0}:{duration.Seconds:00}";
return $"{Math.Truncate(duration.TotalMinutes)}:{duration.Seconds:00}";
}
}