When I click on a picture, I show a pop-up with a video in it. In that pop up, a video is launching automatically. The problem is that I don't have interactivity with the video (play, pause, etc...). So for now, I found the way to loop it with the AVPlayerItemDidPlayToEndTimeNotification but I would like the user has the capability to play/pause.
Here is my code :
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:player];
NSURL *url = [NSURL fileURLWithPath:mediaPath];
player = [[AVPlayer alloc] initWithURL: url];
controller = [[AVPlayerViewController alloc] init];
controller.player = player;
controller.delegate = self;
controller.showsPlaybackControls = YES;
UIImageView *popView = [[[[[[NSBundle mainBundle] loadNibNamed:mediaType owner:self options:nil] objectAtIndex:0] viewLoadedFromXib] subviews] objectAtIndex:0];
[controller.view setFrame:CGRectMake(0, 0, 850, 600)];
First, I think that the UIImageView is not correct as you put a video in it, so I advise you to change in UIView.
UIView *popView = [[[[[[NSBundle mainBundle] loadNibNamed:mediaType owner:self options:nil] objectAtIndex:0] viewLoadedFromXib] subviews]
Second, I think that you may have user interactivity with the video. Try a bigger size to display the bottom bar with controls.
controller.view.frame = CGRectMake(0, 0, 900, 600);//for example