diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 681e318c92..da9c34238e 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -63,6 +63,11 @@ namespace osu.Game.Overlays beatmapSets.Insert(index, beatmapSetInfo); } + /// + /// Returns whether the current beatmap track is playing. + /// + public bool IsPlaying => beatmap.Value.Track.IsRunning; + private void handleBeatmapAdded(BeatmapSetInfo set) => Schedule(() => beatmapSets.Add(set)); @@ -84,15 +89,18 @@ namespace osu.Game.Overlays /// /// Toggle pause / play. /// - public void TogglePause() + /// Whether the operation was successful. + public bool TogglePause() { var track = current?.Track; if (track == null) { - if (!beatmap.Disabled) - next(true); - return; + if (beatmap.Disabled) + return false; + + next(true); + return true; } if (track.IsRunning) @@ -105,12 +113,15 @@ namespace osu.Game.Overlays track.Start(); IsUserPaused = false; } + + return true; } /// /// Play the previous track. /// - public void PrevTrack() + /// Whether the operation was successful. + public bool PrevTrack() { queuedDirection = TrackChangeDirection.Prev; @@ -121,15 +132,20 @@ namespace osu.Game.Overlays if (beatmap is Bindable working) working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value); beatmap.Value.Track.Restart(); + + return true; } + + return false; } /// /// Play the next random or playlist track. /// - public void NextTrack() => next(); + /// Whether the operation was successful. + public bool NextTrack() => next(); - private void next(bool instant = false) + private bool next(bool instant = false) { if (!instant) queuedDirection = TrackChangeDirection.Next; @@ -141,7 +157,10 @@ namespace osu.Game.Overlays if (beatmap is Bindable working) working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value); beatmap.Value.Track.Restart(); + return true; } + + return false; } private WorkingBeatmap current; diff --git a/osu.Game/Overlays/NowPlayingOverlay.cs b/osu.Game/Overlays/NowPlayingOverlay.cs index 98bad5323d..f14adcb53d 100644 --- a/osu.Game/Overlays/NowPlayingOverlay.cs +++ b/osu.Game/Overlays/NowPlayingOverlay.cs @@ -138,7 +138,7 @@ namespace osu.Game.Overlays { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Action = musicController.PrevTrack, + Action = () => musicController.PrevTrack(), Icon = FontAwesome.Solid.StepBackward, }, playButton = new MusicIconButton @@ -147,14 +147,14 @@ namespace osu.Game.Overlays Origin = Anchor.Centre, Scale = new Vector2(1.4f), IconScale = new Vector2(1.4f), - Action = musicController.TogglePause, + Action = () => musicController.TogglePause(), Icon = FontAwesome.Regular.PlayCircle, }, nextButton = new MusicIconButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Action = musicController.NextTrack, + Action = () => musicController.NextTrack(), Icon = FontAwesome.Solid.StepForward, }, }