Im using this code to play a commercial video in my iOS application:
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:[NSString stringWithFormat:@"<iframe width=\"%f\" height=\"%f\" src=%@ frameborder=\"1\" allowfullscreen></iframe>",frame.size.width-10,frame.size.height-10,urlString] baseURL:nil];
[self.view addSubview:videoView];
[videoView release];
}
I want to force the user to see the video and close the UIWebView
once the video is completed without allowing the user to shut the video off.
I think if i can make the Video plays automatically and set the:
videoView.userInteractionEnabled = NO;
that will force the user to watch it.
My Questions:
1- How to force the UIWebView
using <iframe>
?
2- How to detect if the video finished playing?
3- Is there any other way (Better One) to play YouTube
videos in iOS
?
Glad to hear any other ideas or answers, Thanks in advance.