fix crash when back with playing video (#20169)

This commit is contained in:
minggo 2019-09-25 14:33:18 +08:00 committed by GitHub
parent 6de088ab98
commit 42c43a53a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -43,6 +43,10 @@ bool VideoPlayerTest::init()
_visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();
// Should create video first to make sure video is destryed first. If not, then may crash.
// Because when destroying video, it will stop video which may trigger stopped event listener.
createVideo();
MenuItemFont::setFontSize(16);
auto fullSwitch = MenuItemFont::create("FullScreenSwitch", CC_CALLBACK_1(VideoPlayerTest::menuFullScreenCallback, this));
@ -95,8 +99,6 @@ bool VideoPlayerTest::init()
_loopStatusLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
_loopStatusLabel->setPosition(Vec2(_visibleRect.origin.x + _visibleRect.size.width - 10,_visibleRect.origin.y + 185));
_uiLayer->addChild(_loopStatusLabel);
createVideo();
return true;
}