这是我们的代码
NSURL *videoURL = [NSURL URLWithString:strVideo];
playerController = [[AVPlayerViewController alloc]init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[playerController.player currentItem]];
playerController.view.frame = self.view.frame;
playerController.player = [AVPlayer playerWithURL:videoURL];
[self presentViewController:playerController animated:YES completion:nil];
[playerController.player play];
}
- (void)playerItemDidReachEnd:(NSNotification *)notification
{
// [playerController dismissViewControllerAnimated:YES completion:nil];
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
NSLog(@"IT REACHED THE END");
}
视频首先播放2秒,然后从头到尾重播。