diff --git a/cocos/ui/UIVideoPlayer-tizen.cpp b/cocos/ui/UIVideoPlayer-tizen.cpp index ed8c3c0eb1..86f6f17aeb 100644 --- a/cocos/ui/UIVideoPlayer-tizen.cpp +++ b/cocos/ui/UIVideoPlayer-tizen.cpp @@ -298,7 +298,6 @@ void VideoPlayer::play() { player_set_display_mode(impl->_player, PLAYER_DISPLAY_MODE_FULL_SCREEN); } - player_set_display_visible(impl->_player, true); player_set_completed_cb(impl->_player, _player_completed_cb, this); player_set_interrupted_cb(impl->_player, _player_interrupted_cb, this); @@ -309,6 +308,7 @@ void VideoPlayer::play() { this->onPlayEvent((int)VideoPlayer::EventType::PLAYING); } + this->setVisible(true); } } @@ -368,24 +368,33 @@ bool VideoPlayer::isPlaying() const void VideoPlayer::onEnter() { Widget::onEnter(); - this->setVisible(false); + if (isVisible()) + { + _VideoPlayerTizen* impl = (_VideoPlayerTizen*)_videoView; + player_set_display_visible(impl->_player, true); + } } void VideoPlayer::onExit() { Widget::onExit(); - this->setVisible(true); + _VideoPlayerTizen* impl = (_VideoPlayerTizen*)_videoView; + player_set_display_visible(impl->_player, false); } void VideoPlayer::setVisible(bool visible) { cocos2d::ui::Widget::setVisible(visible); + _VideoPlayerTizen* impl = (_VideoPlayerTizen*)_videoView; - if (! _videoURL.empty()) + if (!visible) { - _VideoPlayerTizen* impl = (_VideoPlayerTizen*)_videoView; - player_set_display_visible(impl->_player, visible); - } + player_set_display_visible(impl->_player, false); + } + else if(isRunning()) + { + player_set_display_visible(impl->_player, true); + } } void VideoPlayer::addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback) diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index d595e5189c..deca07c968 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -1262,6 +1262,11 @@ void NodeNameTest::onEnter() this->scheduleOnce(CC_CALLBACK_1(NodeNameTest::test, this), 0.05f, "test_key"); } +void NodeNameTest::onExit() +{ + TestCocosNodeDemo::onExit(); +} + void NodeNameTest::test(float dt) { auto parent = Node::create(); diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.h b/tests/cpp-tests/Classes/NodeTest/NodeTest.h index 66b3b64558..7124f7a708 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.h @@ -325,6 +325,7 @@ public: virtual std::string subtitle() const override; virtual void onEnter() override; + virtual void onExit() override; void test(float dt); };