如何使YouTubevideo开始在UIWebView内自动播放

我有我的应用程序使用此解决scheme(UIWebView中的HTMLstring)embeddedvideo: http : //iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application

不幸的是客户需要他自己的缩略图。 我想通过创buildUIWebView一旦他点击这个缩略图并自动播放video来解决它。

我该怎么做?

尝试这个:-

NSString *htmlString = [NSString stringWithFormat:@"<html><head>" "<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 50\"/></head>" "<body style=\"background:#F00;margin-top:0px;margin-left:0px\">" "<div><object width=\"50\" height=\"50\">" "<param name=\"movie\" value=\"%@\"></param>" "<param name=\"wmode\" value=\"transparent\"></param>" "<embed src=\"%@\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"50\" height=\"50\"></embed>" "</object></div></body></html>",[d objectForKey:@"hrefUrl"],[d objectForKey:@"hrefUrl"]]; [videoView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.your-url.com"]]; 

以下是在UIWebView中自动播放video的HTMLstring…

 NSString *embedHTML = [NSString stringWithFormat:@"<html><body><video controls=\"controls\" autoplay=\"autoplay\"><source src=\"%@\" type=\"video/mp4\"/></video></body></html>", url]; [_webView loadHTMLString:embedHTML baseURL:baseURL]; 

我已经尝试了以下,它工作正常,也开始自动播放。

 NSString *embedHTML = @"<html><body bgcolor="black"><embed id="yt" src="http://www.youtube.com/watch?v=9vyYHVB-QnY"type="application/x-shockwave-flash" width="320.00" height="370.00"></embed></body></html>"; [_webView loadHTMLString:embedHTML baseURL:baseURL];