I\'m trying to set up an AVPlayerViewController completely through storyboards by embedding in a separate View Controller.
Steps:
Unfortunately this bug is still present in ios 10.1. Anyway, I have observed that if I present the view controller with the seekTime set to 0, the bug is not present. So, my solution was to pause the player, retain the currentTime, seek the player to 0, present the controller and on the completion do the following: seek to the retained time and play again.
AVPlayer *player;
AVPlayerViewController *avPlayerController;
CMTime currentTime;
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *videoURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
player = [AVPlayer playerWithURL:videoURL];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
[self.playerView.layer addSublayer:playerLayer];
playerLayer.frame = self.playerView.bounds;
avPlayerController = [[AVPlayerViewController alloc] init];
avPlayerController.player = player;
}
- (IBAction)fullScreen:(id)sender {
[player pause];
currentTime = player.currentTime;
[player seekToTime:CMTimeMake(0, 1)];
[self presentViewController:avPlayerController animated:YES completion:^{
[avPlayerController.player seekToTime:currentTime];
[avPlayerController.player play];
}];
}