Skip to content

Commit 42c43a5

Browse files
authored
fix crash when back with playing video (#20169)
1 parent 6de088a commit 42c43a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ bool VideoPlayerTest::init()
4343

4444
_visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();
4545

46+
// Should create video first to make sure video is destryed first. If not, then may crash.
47+
// Because when destroying video, it will stop video which may trigger stopped event listener.
48+
createVideo();
49+
4650
MenuItemFont::setFontSize(16);
4751

4852
auto fullSwitch = MenuItemFont::create("FullScreenSwitch", CC_CALLBACK_1(VideoPlayerTest::menuFullScreenCallback, this));
@@ -95,8 +99,6 @@ bool VideoPlayerTest::init()
9599
_loopStatusLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
96100
_loopStatusLabel->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 185));
97101
_uiLayer->addChild(_loopStatusLabel);
98-
99-
createVideo();
100102

101103
return true;
102104
}

0 commit comments

Comments
 (0)