I used Saurabh's method but instead of loading a HTML string I was able to just load a normal request and the video still auto-played.
Be sure to set the delegate to nil when you close the webview though or else it will keep trying to play.
- (void)loadVideo
{
NSURLRequest *videoReq = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=J-30wYSsFUY&feature=plcp"]];
[_videoWebView setDelegate:self];
[_videoWebView loadRequest:videoReq];
}
// -----THESE 2 FUNCTIONS TAKEN FROM Saurabh Wadhwa's ANSWER ------
- (UIButton *)findButtonInView:(UIView *)view {
UIButton *button = nil;
if ([view isMemberOfClass:[UIButton class]]) {
return (UIButton *)view;
}
if (view.subviews && [view.subviews count] > 0) {
for (UIView *subview in view.subviews) {
button = [self findButtonInView:subview];
if (button) return button;
}
}
return button;
}
- (void)webViewDidFinishLoad:(UIWebView *)_webView {
UIButton *b = [self findButtonInView:_webView];
[b sendActionsForControlEvents:UIControlEventTouchUpInside];
}