I currently have an MPMoviePlayerController
with controlStyle
set to MPMovieControlStyleNone
.
When the video finishes playing, I want to allow the user to replay the video by touching the video.
I have set a UITapGestureRecognizer
on the MPMoviePlayerController
's view which is correctly calling an event handler when a MPMoviePlayerController
is tapped.
However, I can only seem to obtain the MPMoviePlayerController
's view through the UITapGestureRecognizer
that is passed to the event handler so I can't access the actual MPMoviePlayerController
object to play the video again.
I'm very new to iOS and objective-c development so this may be a silly question. Is there a way I can get a reference to the MPMoviePlayerController
to start playing it again?
Here is the code used to set up the UITapGestureRecognizer:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleMoviePlayerTap:)];
tap.numberOfTapsRequired = 1;
tap.delegate = self;
[_moviePlayer.view addGestureRecognizer:tap];
Here is the handler with nothing implemented yet:
- (void)handleMoviePlayerTap :(UITapGestureRecognizer*) tap
{
NSLog(@"Movie player was tapped");
// Somehow start playing the video again
}