-
Notifications
You must be signed in to change notification settings - Fork 146
finishReason
shixuemei edited this page Dec 19, 2016
·
3 revisions
播放结束的具体原因,如播放完成,播放出现错误等
typedef NS_ENUM(NSInteger, MPMovieFinishReason) {
MPMovieFinishReasonPlaybackEnded,
MPMovieFinishReasonPlaybackError,
MPMovieFinishReasonUserExited
};
- MPMovieFinishReasonPlaybackEnded - 播放结束
- MPMovieFinishReasonPlaybackError - 播放错误
- MPMovieFinishReasonUserExited - 用户主动退出
- 当接收到MPMoviePlayerPlaybackDidFinishNotification通知时,可通过userInfo字典中关键字MPMoviePlayerPlaybackDidFinishReasonUserInfoKey查询具体的结束原因
- 当结束原因为MPMovieFinishReasonPlaybackError时,userInfo字典中的关键字error指明了具体的错误码。
if (MPMoviePlayerPlaybackDidFinishNotification == notify.name) {
NSLog(@"player finish state: %ld", (long)_player.playbackState);
int reason = [[[notify userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
if (reason == MPMovieFinishReasonPlaybackEnded) {
stat.text = [NSString stringWithFormat:@"player finish"];
}else if (reason == MPMovieFinishReasonPlaybackError){
stat.text = [NSString stringWithFormat:@"player Error : %@", [[notify userInfo] valueForKey:@"error"]];
}else if (reason == MPMovieFinishReasonUserExited){
stat.text = [NSString stringWithFormat:@"player userExited"];
}
}