Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 56dda68

Browse files
authored
Merge pull request #16300 from inky03/yippee
fix video crash when exiting state
2 parents 95f9eac + c610d9c commit 56dda68

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

source/objects/VideoSprite.hx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class VideoSprite extends FlxSpriteGroup {
4646
if(canSkip) this.canSkip = true;
4747

4848
// callbacks
49-
if(!shouldLoop) videoSprite.bitmap.onEndReached.add(destroy);
49+
if(!shouldLoop) videoSprite.bitmap.onEndReached.add(finishVideo);
5050

5151
videoSprite.bitmap.onFormatSetup.add(function()
5252
{
@@ -79,9 +79,8 @@ class VideoSprite extends FlxSpriteGroup {
7979
remove(cover);
8080
cover.destroy();
8181
}
82-
83-
if(finishCallback != null)
84-
finishCallback();
82+
83+
finishCallback = null;
8584
onSkip = null;
8685

8786
if(FlxG.state != null)
@@ -95,6 +94,16 @@ class VideoSprite extends FlxSpriteGroup {
9594
super.destroy();
9695
alreadyDestroyed = true;
9796
}
97+
function finishVideo()
98+
{
99+
if (!alreadyDestroyed)
100+
{
101+
if(finishCallback != null)
102+
finishCallback();
103+
104+
destroy();
105+
}
106+
}
98107

99108
override function update(elapsed:Float)
100109
{

0 commit comments

Comments
 (0)