3

我遇到了一个相当奇怪的问题。我现在要做的只是获取给定链接的 YouTube 视频的音频。我已经尝试了几件事,但它要么不起作用,要么效率不高。

因此,我决定在这里询问更有经验的 iOS 开发人员。提前致谢。

@implementation ViewController
@synthesize web;

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

        UIWebView *webView =[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
        [webView loadHTMLString:html baseURL:nil];
        [self.view addSubview:webView];
}

-(IBAction)play{

    [self embedYouTube:@"http://www.youtube.com/watch?v=iw1aT5c1Lus" frame:CGRectMake(0, 0, 320, 480)];

}
4

1 回答 1

4

just play the video with your media player, but dont give it a frame, this will play the audio, but not load the image

于 2012-04-25T23:32:31.967 回答