I'm trying to embed youtube video and autoplay it on my app. The code is not working on iOS6, however it runs on older iOS 5 perfectly.
I do it in this way:
-(IBAction)playVideo:(id)sender {
myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
myWebView.delegate = self;
[myWebView setAllowsInlineMediaPlayback:YES];
myWebView.mediaPlaybackRequiresUserAction=NO;
[myWebView loadHTMLString:[NSString stringWithFormat:@"<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" width=\"300\" height=\"300\"></embed>", @"http://www.youtube.com/watch?v=TbsXUJITa40"] baseURL:nil];
}
- (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];
}
So- when the webview is loaded, it finds automatically the uibutton and the video starts. I can't understand, why in iOS 6 this method doesn't work anymore. It loads the video, but nothing appears...
Anyone can help me? I'm going crazy to try to solve it...