diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneNowPlayingOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneNowPlayingOverlay.cs
index 2ea9aec50a..e2913833a7 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneNowPlayingOverlay.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneNowPlayingOverlay.cs
@@ -47,18 +47,19 @@ namespace osu.Game.Tests.Visual.UserInterface
[Test]
public void TestPrevTrackBehavior()
{
- AddStep(@"Play track", () =>
- {
- musicController.NextTrack();
- currentBeatmap = Beatmap.Value;
- });
+ AddStep(@"Next track", () => musicController.NextTrack());
+ AddStep("Store track", () => currentBeatmap = Beatmap.Value);
AddStep(@"Seek track to 6 second", () => musicController.SeekTo(6000));
AddUntilStep(@"Wait for current time to update", () => currentBeatmap.Track.CurrentTime > 5000);
- AddAssert(@"Check action is restart track", () => musicController.PreviousTrack() == PreviousTrackResult.Restart);
- AddUntilStep("Wait for current time to update", () => Precision.AlmostEquals(currentBeatmap.Track.CurrentTime, 0));
+
+ AddStep(@"Set previous", () => musicController.PreviousTrack());
+
AddAssert(@"Check track didn't change", () => currentBeatmap == Beatmap.Value);
- AddAssert(@"Check action is not restart", () => musicController.PreviousTrack() != PreviousTrackResult.Restart);
+ AddUntilStep("Wait for current time to update", () => currentBeatmap.Track.CurrentTime < 5000);
+
+ AddStep(@"Set previous", () => musicController.PreviousTrack());
+ AddAssert(@"Check track did change", () => currentBeatmap != Beatmap.Value);
}
}
}
diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs
index d788929739..6d269aa944 100644
--- a/osu.Game/Overlays/MusicController.cs
+++ b/osu.Game/Overlays/MusicController.cs
@@ -172,10 +172,15 @@ namespace osu.Game.Overlays
}
///
- /// Play the previous track or restart the current track if it's current time below
+ /// Play the previous track or restart the current track if it's current time below .
///
- /// The that indicate the decided action
- public PreviousTrackResult PreviousTrack()
+ public void PreviousTrack() => Schedule(() => prev());
+
+ ///
+ /// Play the previous track or restart the current track if it's current time below .
+ ///
+ /// The that indicate the decided action.
+ private PreviousTrackResult prev()
{
var currentTrackPosition = current?.Track.CurrentTime;
@@ -204,8 +209,7 @@ namespace osu.Game.Overlays
///
/// Play the next random or playlist track.
///
- /// Whether the operation was successful.
- public bool NextTrack() => next();
+ public void NextTrack() => Schedule(() => next());
private bool next(bool instant = false)
{
@@ -319,13 +323,13 @@ namespace osu.Game.Overlays
return true;
case GlobalAction.MusicNext:
- if (NextTrack())
+ if (next())
onScreenDisplay?.Display(new MusicControllerToast("Next track"));
return true;
case GlobalAction.MusicPrev:
- switch (PreviousTrack())
+ switch (prev())
{
case PreviousTrackResult.Restart:
onScreenDisplay?.Display(new MusicControllerToast("Restart track"));