如何在UITableViewCell上点击iPhone应用程序上的YouTube电影? [英] How to play YouTube Movie on an iPhone Application when tapped on UITableViewCell?

查看:115
本文介绍了如何在UITableViewCell上点击iPhone应用程序上的YouTube电影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone开发的新手,刚开始开发一个包含UITableView的应用程序,其中每个单元格都包含webview视频缩略图。为了在iPhone上嵌入YouTube播放器,我使用了以下代码。

I'm a newbie to iPhone development and just started on developing an application that contains a UITableView where each cell consisting of youtube video thumbnails in the form of webviews. For embedding YouTube Player on iPhone, I have used the follwing piece of code.

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

}

现在我可以看到tableviewcell上的缩略图,一旦我点击缩略图,YouTube播放器就会打开并播放电影。

Now that I can see the thumbnail on the tableviewcell and once I tap on the thumbnail, YouTube player opens and play the movie.

我的缩略图仅占据单元格的一小部分,其余部分单元格的区域包含一些文本描述。我的问题是我必须完全点击缩略图才能播放电影。如果我点击单元格上的其他位置然后它将无法播放,因为我的缩略图不会遍布单元格。

My thumbnail occupies only a small portion of the cell and the rest of the area of the cell contains some text descriptions. My problem is that I must tap exactly on the thumbnail for the movie to play. If I tap somewhere else on the cell then it wouldn't play because my thumbnail doesn't extend all over the cell.

是否有办法使要在 didSelectRowAtIndexPath 中播放的电影?我看到一些人建议使用Javascript,但似乎没有人知道如何正确使用它来解决这个问题。

Isn't there a way to make the movie to play in didSelectRowAtIndexPath? I have seen some chaps suggest using Javascript but nobody seem to have an idea on the correct way of using it for this problem.

如果有人可以提供帮助,请高度赞赏。

Highly appreciate it if anybody can help.

推荐答案

我建议你看看 YouTube API 并尝试弄清楚你的真正问题是什么。但另一个好的链接是如何玩应用程序中的YouTube视频。希望我能帮到你。

I suggest you to take a look at YouTube APIs and try to figure it out what is your real problem. but another good link is How To Play YouTube Videos Within an Application. Hope I'm helping you.

这篇关于如何在UITableViewCell上点击iPhone应用程序上的YouTube电影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆