【发布时间】:2011-05-05 23:21:59
【问题描述】:
我正在尝试在 UIWebView 中播放 youtube 视频,而不是离开我的应用程序。
Google 认为很容易-http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html
所以我的 GData 框架和标头运行良好,而且我在查询、加载用户的视频源等方面没有问题。
但我似乎无法加载特定视频的供稿。 我提前知道我想要订阅源的视频的 ID。如何加载特定视频的供稿?
然后我将按照 google 的说明进行操作:
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 = @"<html><head>
<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>
<body style=\"background:#F00;margin-top:0px;margin-left:0px\">
<div><object width=\"212\" height=\"172\">
<param name=\"movie\" value=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"></param>
<param name=\"wmode\" value=\"transparent\"></param>
<embed src=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"
type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"212\" height=\"172\"></embed>
</object></div></body></html>";
[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.your-url.com"]];
任何帮助将不胜感激!
【问题讨论】:
标签: iphone objective-c youtube youtube-api