mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Fix user pause not being cancelled when playing audio
This commit is contained in:
parent
f74c79c2b8
commit
e66f9adb86
@ -98,20 +98,13 @@ namespace osu.Game.Overlays
|
||||
/// <summary>
|
||||
/// Start playing the current track (if not already playing).
|
||||
/// </summary>
|
||||
public void Play()
|
||||
{
|
||||
if (!IsPlaying)
|
||||
TogglePause();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggle pause / play.
|
||||
/// </summary>
|
||||
/// <returns>Whether the operation was successful.</returns>
|
||||
public bool TogglePause()
|
||||
public bool Play(bool restart = false)
|
||||
{
|
||||
var track = current?.Track;
|
||||
|
||||
IsUserPaused = false;
|
||||
|
||||
if (track == null)
|
||||
{
|
||||
if (beatmap.Disabled)
|
||||
@ -121,16 +114,40 @@ namespace osu.Game.Overlays
|
||||
return true;
|
||||
}
|
||||
|
||||
if (restart)
|
||||
track.Restart();
|
||||
else if (!IsPlaying)
|
||||
track.Start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop playing the current track and pause at the current position.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
var track = current?.Track;
|
||||
|
||||
if (track.IsRunning)
|
||||
{
|
||||
IsUserPaused = true;
|
||||
track.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggle pause / play.
|
||||
/// </summary>
|
||||
/// <returns>Whether the operation was successful.</returns>
|
||||
public bool TogglePause()
|
||||
{
|
||||
var track = current?.Track;
|
||||
|
||||
if (track?.IsRunning == true)
|
||||
Stop();
|
||||
else
|
||||
{
|
||||
track.Start();
|
||||
IsUserPaused = false;
|
||||
}
|
||||
Play();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -597,12 +597,7 @@ namespace osu.Game.Screens.Select
|
||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||
|
||||
if (!track.IsRunning && (music?.IsUserPaused != true || isNewTrack))
|
||||
{
|
||||
if (fromPreviewPoint)
|
||||
track.Restart();
|
||||
else
|
||||
track.Start();
|
||||
}
|
||||
music?.Play(fromPreviewPoint);
|
||||
|
||||
lastTrack.SetTarget(track);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user