-
GurudathLikes 0Problem Description
I have created Video Player.
_videoPlayer = VideoPlayer::create();
_videoPlayer->setPosition(centerPos);
_videoPlayer->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_videoPlayer->setContentSize(Size(visibleSize.width/2,visibleSize.height/2));
_tLayer->addChild(_videoPlayer);
_videoPlayer->setTouchEnabled(true);
_videoPlayer->setFileName("cocosvideo.mp4");
_videoPlayer->play();
_tLayer->addTouchEventListener([=](Ref* sender, Widget::TouchEventType type)
{
if (type == Widget::TouchEventType::BEGAN) {
}
if (type == Widget::TouchEventType::ENDED)
{
if (_videoPlayer->isPlaying())
_videoPlayer->pause();
else
_videoPlayer->play();
}
});
Touch Listner is not at all working. How can i Add Touch Event?
-
Sonar Systems adminLikes 0
Do you get any warnings/errors in the console.
-
GurudathLikes 0
No. Am not getting Any error.
I have added Touch Listner for Widget. It was not working.
I have added Touch Event Dispatcher for Layer. Now its working fine.
Anyway Thanks for the quick response
-
Sonar Systems adminLikes 0
Fantastic to hear. Feel free to post this as a solution as I am positive many other developers will face the same issue.
Don’t forget that if you have anymore questions feel free to post them on our education platform sonarlearning.co.uk
Login to reply