首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cocos2D-x;ui不被识别为命名空间

Cocos2D-x;ui不被识别为命名空间
EN

Stack Overflow用户
提问于 2017-06-23 22:53:03
回答 1查看 487关注 0票数 0

我知道这可能是最基本的,但我不知道为什么会发生这种事。我试着在HelloWorldScene.cpp中放一个视频,只是为了尝试一下,使用实验性的::ui::视频播放器,就像看到的这里。

这是一个错误的图片:http://i.imgur.com/z1NcqH1.png,我看了一个视频教程,它对他很好。提前感谢!

代码语言:javascript
复制
#include "HelloWorldScene.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"

USING_NS_CC;

//using namespace cocostudio::timeline;

Scene* HelloWorld::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();

// 'layer' is an autorelease object
auto layer = HelloWorld::create();

// add layer as a child to scene
scene->addChild(layer);

// return the scene
return scene;
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
    return false;
}

auto rootNode = CSLoader::createNode("MainScene.csb");

addChild(rootNode);

const cocos2d::Size visibleSize(cocos2d::Director::getInstance()->getVisibleSize());
cocos2d::experimental::ui::VideoPlayer testvideo = cocos2d::experimental::ui::VideoPlayer::create();
testvideo->setContentSize(visibleSize);
testvideo->setAnchorPoint(cocos2d::Vec2::ANCHOR_MIDDLE);
testvideo->setPosition(visibleSize / 2);
testvideo->setURL("https://www.youtube.com/watch?v=Y2V6yjjPbX0");
addChild(testvideo);
testvideo->play();

        return true;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-24 10:13:26

在所有平台上都不支持VideoPlayer

如果在Xcode上运行,请确保选择了Test-mobile方案,而不是Test-desktop方案

否则使用平台预处理器

代码语言:javascript
复制
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

    cocos2d::experimental::ui::VideoPlayer* testvideo = cocos2d::experimental::ui::VideoPlayer::create();
    testvideo->setContentSize(visibleSize);
    testvideo->setPosition(Vec2(origin.x + visibleSize.width/2,
                                origin.y + visibleSize.height/2));
    testvideo->setURL("https://www.w3schools.com/html/mov_bbb.mp4");
    addChild(testvideo);
    testvideo->play();

#endif 

你不能通过流媒体在你的应用程序中播放youtube视频,这是不允许的。在官方的YouTube视频播放器之外播放视频是违反服务条款的。只允许浏览器中的flash/html播放器或中包含的播放器。

有关更多细节,请查看此讨论

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44730953

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档