Skip to content

Instantly share code, notes, and snippets.

@gin0606
Created June 13, 2014 08:33
Show Gist options
  • Save gin0606/5f254961555587b5122e to your computer and use it in GitHub Desktop.
Save gin0606/5f254961555587b5122e to your computer and use it in GitHub Desktop.
bool VideoPlayerScene::init() {
if (!Scene::init()) {return false;}
auto visibleSize = Director::getInstance()->getVisibleSize();
auto videoPlayer = cocos2d::experimental::ui::VideoPlayer::create();
videoPlayer->setContentSize(visibleSize);
videoPlayer->setPosition(Vec2(visibleSize.width/2, visibleSize.height / 2));
videoPlayer->setEnabled(false);
videoPlayer->setKeepAspectRatioEnabled(true);
this->addChild(videoPlayer);
auto menu = Menu::createWithItem(MenuItemLabel::create(Label::createWithSystemFont("Play", "Arial", 24),
[videoPlayer](Ref *sender) {
videoPlayer->setFileName("video.mp4");
videoPlayer->play();
}
));
menu->setPosition(visibleSize / 2);
this->addChild(menu);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment