From ea624b8ad0fa0d9fd78e192edb986abb360f6b3f Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 13 Feb 2023 22:39:34 -0800 Subject: [PATCH] Reset preview track when stopping instead --- osu.Game/Audio/PreviewTrack.cs | 3 +++ osu.Game/Beatmaps/Drawables/Cards/Buttons/PlayButton.cs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Audio/PreviewTrack.cs b/osu.Game/Audio/PreviewTrack.cs index 2c63c16274..d625566ee7 100644 --- a/osu.Game/Audio/PreviewTrack.cs +++ b/osu.Game/Audio/PreviewTrack.cs @@ -98,6 +98,9 @@ namespace osu.Game.Audio Track.Stop(); + // Ensure the track is reset immediately on stopping, so the next time it is started it has a correct time value. + Track.Seek(0); + Stopped?.Invoke(); } diff --git a/osu.Game/Beatmaps/Drawables/Cards/Buttons/PlayButton.cs b/osu.Game/Beatmaps/Drawables/Cards/Buttons/PlayButton.cs index 8304cdfc08..f808fd21b7 100644 --- a/osu.Game/Beatmaps/Drawables/Cards/Buttons/PlayButton.cs +++ b/osu.Game/Beatmaps/Drawables/Cards/Buttons/PlayButton.cs @@ -75,9 +75,9 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons Playing.BindValueChanged(updateState, true); } - protected override void UpdateAfterChildren() + protected override void Update() { - base.UpdateAfterChildren(); + base.Update(); if (Playing.Value && previewTrack != null && previewTrack.TrackLoaded) progress.Value = previewTrack.CurrentTime / previewTrack.Length;