Hello, I want to play a video file (which is in my resourse folder ). It works fine on iOS devices but when i try to do the same on an android device, I get a pop us which reads “Video problem: Can’t play the video”. I tried different formats like .mp4, .mov but no luck.
I downloaded the test project too and ran it on my device to test but my app crashes when I follow this navigation.
53: Node: UI > cocosStudioParsetest/custom GUI test > crash
Please tell if I am doing something wrong?
I can not find UIVideoPlayer anywhere in the app. Everthing under the above navigation is crashing.
Can somebody help me out on this? Here is what I am getting on Andoird Device
Thanks
Here is my code.
Scene* SplashScreen::createScene()
{
auto scene = Scene::create();
auto layer = SplashScreen::create();
scene->addChild(layer);
return scene;
}
// on “init” you need to initialize your instance
bool SplashScreen::init()
{
if ( !Layer::init() )
{
return false;
}
isVideoEnded=false;
Director::getInstance()->setContentScaleFactor(1);
CCLOG("\n\n\n\n\n\n\nplay\n\n\n\n\n\n\n");
visibleSize = Director::getInstance()->getVisibleSize();
Director::getInstance()->setContentScaleFactor(2);
SplashVid=VideoPlayer::create();
SplashVid->setContentSize(Size(visibleSize.width1.5, visibleSize.height1.5));
SplashVid->setPosition(Vec2( visibleSize.width/2, visibleSize.height/2));
SplashVid->setKeepAspectRatioEnabled(true);
this->addChild(SplashVid);
SplashVid->setFileName(“res/jojo.mp4”);
SplashVid->play();
SplashVid->addEventListener(CC_CALLBACK_2(SplashScreen::VideoEventCallback, this));
this->scheduleUpdate();
return true;
}
void SplashScreen::VideoEventCallback(cocos2d::Ref *sender, cocos2d::experimental::ui::VideoPlayer::EventType eventType)
{
isVideoEnded=true;
}
void SplashScreen::update(float dt)
{
if (isVideoEnded)
{
Director::getInstance()->replaceScene(Gameplay::createScene());
isVideoEnded=false;
}
}
