Properly handle pausing sounds with negative startTime

This commit is contained in:
Mike Welsh 2024-03-04 03:43:17 -08:00
parent 5557dbf28f
commit 5d00f57bfb
1 changed files with 16 additions and 3 deletions

View File

@ -172,8 +172,18 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
public override function pause():FunkinSound
{
super.pause();
this._shouldPlay = false;
if (_shouldPlay)
{
// This sound will eventually play, but is still at a negative timestamp.
// Manually set the paused flag to ensure proper focus/unfocus behavior.
_shouldPlay = false;
_paused = true;
active = false;
}
else
{
super.pause();
}
return this;
}
@ -211,7 +221,10 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
{
if (this._time < 0)
{
this._shouldPlay = true;
// Sound with negative timestamp, restart the timer.
_shouldPlay = true;
_paused = false;
active = true;
}
else
{