I have a html button in UIWebView, which on click pushes a UIViewController with programmed segue action. How to play a movie upon loading of the UIViewController with MPMoviePlayer. This code plays the Movie in MPMoviePlayerViewController instead of the segue pushed UIViewController. I want to play the movie in the UIViewController pushed by segue.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ([request.URL.scheme isEqualToString:@"inapp"]) {
if ([request.URL.host isEqualToString:@"capture"]) {
[self performSegueWithIdentifier: @"SegueAction" sender: self];
NSURL * urlA1 = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"A1"ofType:@"mp4"]];
MPMoviePlayerViewController *playercontrollerA1 = [[MPMoviePlayerViewController alloc] initWithContentURL:urlA1];
playercontrollerA1.moviePlayer.repeatMode = MPMovieRepeatModeOne;
[self presentMoviePlayerViewControllerAnimated:playercontrollerA1];
playercontrollerA1.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
// do capture action
}
return NO;
}
return YES;
}
Use MPMoviePlayerController . You can add that as a subview of
self.view.For eg:
Fore more details please check the apple doc link above.
Update: