在UIWebview,iOS的video自动播放

我有例如https://www.youtube.com/watch?v=c2ccXwwmcnA 。 如果我将这个URL传递给UIWebView它会自动playvideo。 我有以下方法尝试

选项1

 @property (weak, nonatomic) IBOutlet UIWebView *webvie; NSString *url=@"https://www.youtube.com/watch?v=7jYa7dfrXKU"; self.webvie.allowsInlineMediaPlayback = YES; self.webvie.scrollView.bounces = NO; self.webvie.mediaPlaybackRequiresUserAction = NO; [self.webvie loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; 

选项2

 NSString *youTubeHTMLTemplate = @"<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>"; finalHtml = [NSString stringWithFormat:youTubeHTMLTemplate, fullYopuTubeUrl, htmlFrameWidth, htmlFrameHeight]; 

选项-3

如何在UIWebView中自动播放YouTubevideo

我不想自动播放在UIWebview播放YouTubevideo

但所有的select不帮助我,

谢谢@Kyle,我尝试了你的评论,我在完美的URL后面添加了&autoplay=1 。 答案是

 NSString *url=@"https://www.youtube.com/watch?v=7jYa7dfrXKU&autoplay=1"; [self.webvie loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; self.webvie.scrollView.bounces = NO; [self.webvie setMediaPlaybackRequiresUserAction:NO];