我知道如何将youtube添加到视图中。但我们使用的是CCScene(cocos2d),我需要打开一个youtube并从一个场景中播放它。
我该怎么做呢?
我知道如何添加一个子视图:
- (void)embedYouTube:(NSString*)url frame:(CGRect)frame {
NSString* embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString* html = [NSString stringWithFormat:embedHTML, url, frame.size.width, frame.size.height];
if(videoView == nil) {
videoView = [[UIWebView alloc] initWithFrame:frame];
[self.view addSubview:videoView];
}
[videoView loadHTMLString:html baseURL:nil];
} 任何帮助都是最好的。谢谢
发布于 2012-05-24 17:33:56
[[CCDirector sharedDirector].openGLView addSubview:videoView];如果您使用的是cocos2d 2.0,那么openGLView属性就叫做view。
https://stackoverflow.com/questions/10733820
复制相似问题