我试图在UIWebView中播放YouTube视频而不是离开我的应用程序.
Google认为很容易让人感到轻松 - http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html
所以我让GData框架和标头工作得很好,我在查询,加载用户的视频源等方面没有问题.
但我似乎无法加载特定视频的Feed.我知道我想要提前输入的视频的ID.如何加载特定视频的Feed?
然后我将按照谷歌的指示:
Grab the video url from the media tag in the API response with the application/x-shockwave-flash type.
然后像这样嵌入它:
// webView is a UIWebView, either initialized programmatically or loaded as part of a xib. NSString *htmlString = @" "; [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.your-url.com"]];
任何帮助将非常感激!
如果提供YouTube视频条目,您可以通过以下方式获取每个条目的ID和Flash网址:
for (GDataEntryYouTubeVideo *videoEntry in [feed entries]) { GDataYouTubeMediaGroup *mediaGroup = [videoEntry mediaGroup]; NSString *videoID = [mediaGroup videoID]; NSArray *mediaContents = [mediaGroup mediaContents]; GDataMediaContent *flashContent = [GDataUtilities firstObjectFromArray:mediaContents withValue:@"application/x-shockwave-flash" forKeyPath:@"type"]; NSLog(@"video ID = %@, flash content URL = %@", videoID, [flashContent URLString]); }