2012-04-25 17 views
3

我遇到了一個相當奇怪的問題。我現在想要做的只是獲得給定鏈接的YouTube視頻的音頻。我嘗試了幾件事情,但它沒有奏效或效率不高。如何才能讓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

只是發揮你的媒體播放器的視頻,但不給它一個框架,這將播放音頻,但不能加載圖像

+0

謝謝你的答案。我已經改變了網頁和embedYoutube框架的框架,但它不起作用。我上傳了我的代碼。 再次感謝 – 2012-04-26 20:36:16

+0

仍然無法做到,請你能幫助我嗎? – 2012-04-28 10:57:41