首页 新闻 搜索 专区 学院

MPMoviePlayerViewController怎么连续播放视频

0
悬赏园豆:200 [已关闭问题] 关闭于 2016-11-01 10:26

以下是我写的的连续播放视频代码,按钮点击后,可以正常播放第一个视频,播放完毕发送通知,实现方法,再创建播放第二个视频,就失败了,错误信息: 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];
}
ios
liu_weixing的主页 liu_weixing | 初学一级 | 园豆:3
提问于:2015-08-05 17:25
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册