28using namespace cocos2d::ui;
30VideoPlayerTests::VideoPlayerTests()
43 _visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();
49 MenuItemFont::setFontSize(16);
52 fullSwitch->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
56 pauseItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
60 resumeItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
64 stopItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
68 hintItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
73 resourceVideo->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
77 onlineVideo->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
81 ratioSwitch->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
85 loopToggle->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
88 auto menu = Menu::create(resourceVideo,onlineVideo,ratioSwitch,loopToggle,fullSwitch,pauseItem,resumeItem,stopItem,hintItem,
nullptr);
89 menu->setPosition(Vec2::ZERO);
107 Director::getInstance()->end();
149 _videoPlayer->setURL(
"http://benchmark.cocos2d-x.org/cocosvideo.mp4");
190 auto widgetSize =
_widget->getContentSize();
195 _videoPlayer->setContentSize(Size(widgetSize.width * 0.4f,widgetSize.height * 0.4f));
205 auto hSlider = ui::Slider::create();
206 hSlider->setTouchEnabled(
true);
207 hSlider->loadBarTexture(
"cocosui/sliderTrack.png");
208 hSlider->loadSlidBallTextures(
"cocosui/sliderThumb.png",
"cocosui/sliderThumb.png",
"");
209 hSlider->loadProgressBarTexture(
"cocosui/sliderProgress.png");
211 hSlider->setPercent(50);
215 auto vSlider = ui::Slider::create();
216 vSlider->setTouchEnabled(
true);
217 vSlider->loadBarTexture(
"cocosui/sliderTrack.png");
218 vSlider->loadSlidBallTextures(
"cocosui/sliderThumb.png",
"cocosui/sliderThumb.png",
"");
219 vSlider->loadProgressBarTexture(
"cocosui/sliderProgress.png");
221 vSlider->setRotation(90);
222 vSlider->setPercent(50);
229 if (eventType == Slider::EventType::ON_PERCENTAGE_CHANGED &&
_videoPlayer)
231 Slider* hSlider = (Slider*)this->getChildByTag(1);
232 Slider* vSlider = (Slider*)this->getChildByTag(2);
244 case VideoPlayer::EventType::PLAYING:
247 case VideoPlayer::EventType::PAUSED:
250 case VideoPlayer::EventType::STOPPED:
253 case VideoPlayer::EventType::COMPLETED:
267 _style = cocos2d::ui::VideoPlayer::StyleType::NONE;
278 std::string str =
_userInputEnabled ?
"< User Input Enabled >" :
"< User Input Disabled >";
284 std::string str =
" - ";
287 case cocos2d::ui::VideoPlayer::StyleType::NONE:
289 str =
"< NO Sytle >";
292 case cocos2d::ui::VideoPlayer::StyleType::DEFAULT:
293 str =
"< Default Style >";
312 _visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();
314 MenuItemFont::setFontSize(16);
325 menu->setPosition(Vec2::ZERO);
336 Director::getInstance()->end();
338#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
347 case cocos2d::ui::VideoPlayer::StyleType::NONE:
348 _style = cocos2d::ui::VideoPlayer::StyleType::DEFAULT;
351 case cocos2d::ui::VideoPlayer::StyleType::DEFAULT:
352 _style = cocos2d::ui::VideoPlayer::StyleType::NONE;
389 auto widgetSize =
_widget->getContentSize();
394 _videoPlayer->setContentSize(Size(widgetSize.width * 0.4f,widgetSize.height * 0.4f));
#define ADD_TEST_CASE(__className__)
void menuCloseCallback(cocos2d::Ref *sender)
void updateButtonsTexts()
cocos2d::ui::VideoPlayer::StyleType _style
cocos2d::MenuItemFont * _switchUserInputEnabled
cocos2d::MenuItemFont * _switchStyle
cocos2d::ui::VideoPlayer * _videoPlayer
virtual bool init() override
void switchStyleCallback(cocos2d::Ref *sender)
void switchUserInputCallback(cocos2d::Ref *sender)
cocos2d::Rect _visibleRect
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget
void menuStopCallback(cocos2d::Ref *sender)
void videoEventCallback(cocos2d::Ref *sender, cocos2d::ui::VideoPlayer::EventType eventType)
cocos2d::Rect _visibleRect
cocos2d::ui::VideoPlayer * _videoPlayer
void sliderCallback(cocos2d::Ref *sender, cocos2d::ui::Slider::EventType eventType)
void menuCloseCallback(cocos2d::Ref *sender)
cocos2d::Label * _loopStatusLabel
virtual bool init() override
void menuFullScreenCallback(cocos2d::Ref *sender)
void menuOnlineVideoCallback(cocos2d::Ref *sender)
void menuRatioCallback(cocos2d::Ref *sender)
cocos2d::Label * _videoStateLabel
void menuLoopCallback(cocos2d::Ref *sender)
void menuPauseCallback(cocos2d::Ref *sender)
void menuResumeCallback(cocos2d::Ref *sender)
void menuResourceVideoCallback(cocos2d::Ref *sender)
void menuHintCallback(cocos2d::Ref *sender)