NSURL *videoURL = [NSURL URLWithString:strVideo];
playerController = [[AVPlayerViewController alloc]init];
playerController.player = [AVPlayer playerWithURL:videoURL];
playerController.view.frame = self.view.frame;
playerController.player.currentItem.forwardPlaybackEndTime = CMTimeMake(timeDuration, 1);
[playerController.player play];
playerController.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[self presentViewController:playerController animated:YES completion:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[playerController.player currentItem]];
- (void)playerItemDidReachEnd:(NSNotification *)notification
{
[playerController dismissViewControllerAnimated:YES completion:nil];
NSLog(@"IT REACHED THE END");
}
这里调用了playerItemDidReachEnd
但avplayercontroller
没有被解雇。
答案 0 :(得分:0)
我认为你必须删除下面的代码行,
playerController.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
它可能无法调用您的通知方法。只需删除代码并试一试。