2012-05-24 4 views
0

Я знаю, как добавить youtube в представление. , но мы используем CCScene (cocos2d), и мне нужно открыть YouTube и воспроизвести его со сцены.добавление youtube в CCScene?

как бы я это сделал?

я знаю, как сделать это с добавлением подвид:

- (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]; 
} 

любая помощь будет большим. Thanx

ответ

0
[[CCDirector sharedDirector].openGLView addSubview:videoView]; 

Если вы используете Cocos2D 2.0 openGLView свойство называется просто view.

Смежные вопросы