以下是我写的的连续播放视频代码,按钮点击后,可以正常播放第一个视频,播放完毕发送通知,实现方法,再创建播放第二个视频,就失败了,错误信息: whose view is not in the window hierarchy!
求哪位大神帮忙看下,谢谢!
- (void)viewDidLoad { [super viewDidLoad]; //视频播放完通知 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; } /**视频播放完通知的事件,播放下一个视频*/ -(void)moviePlayBackDidFinish:(NSNotification *)aNotification { self.mvc = nil; self.currentIndex++; if (self.currentIndex >= self.pathArray.count) { return; } self.mvc = [[TRMoviePlayerViewController alloc]initWithContentURL:self.pathArray[self.currentIndex]]; self.mvc.moviePlayer.contentURL =self.pathArray[self.currentIndex]; [self presentMoviePlayerViewControllerAnimated:self.mvc]; } //按钮开始播放第一个视频 - (IBAction)move:(UIButton *)sender { self.mvc = nil; self.currentIndex = 0; TRMoviePlayerViewController *mvc = [[TRMoviePlayerViewController alloc]initWithContentURL:self.pathArray[self.currentIndex]]; [self presentMoviePlayerViewControllerAnimated:mvc]; }