NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"thoughtcastAnimate_v02" withExtension:@"mov"];
// create an AVPlayer
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
controller.showsPlaybackControls = false;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying) name:AVPlayerItemDidPlayToEndTimeNotification object: player];//edited
controller.player = player;
// show the view controller
[self addChildViewController:controller];
[self.view addSubview:controller.view];
controller.view.frame = self.view.frame;
[player play];
itemDidFinishPlaying永远不会被调用?!
我不明白为什么。 也许我的NSNotificationCenter问题无效。或者也许是其中一个参数。不确定。