我有URL例如https://www.youtube.com/watch?v=c2ccXwwmcnA.如果我将此URL UIWebView自动传递给play视频.我试过以下方法
选项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]]];
Run Code Online (Sandbox Code Playgroud)
选项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];
Run Code Online (Sandbox Code Playgroud)
选项-3
但所有选择都没有帮助我,