-
Notifications
You must be signed in to change notification settings - Fork 146
errorCode
shixuemei edited this page May 11, 2017
·
7 revisions
出现错误无法播放时通过MPMoviePlayerPlaybackDidFinishNotification通知发送具体的错误原因
变量名 | 数值 | 含义 | 备注 |
---|---|---|---|
KSYMPErrorCodeUnknownError | 1 | 未知的播放器错误 | |
KSYMPErrorCodeFileIOError | -1004 | 文件或网络相关操作错误 | |
KSYMPErrorCodeUnsupportProtocol | -10001 | 不支持的流媒体协议 | |
KSYMPErrorCodeDNSParseFailed | -10002 | DNS解析失败 | |
KSYMPErrorCodeCreateSocketFailed | -10003 | 创建socket失败 | |
KSYMPErrorCodeConnectServerFailed | -10004 | 连接服务器失败 | |
KSYMPErrorCodeBadRequest | -10005 | http请求返回400 | |
KSYMPErrorCodeUnauthorizedClient | -10006 | http请求返回401 | |
KSYMPErrorCodeAccessForbidden | -10007 | http请求返回403 | |
KSYMPErrorCodeTargetNotFound | -10008 | http请求返回404 | |
KSYMPErrorCodeOtherErrorCode | -10009 | http请求返回4xx | |
KSYMPErrorCodeServerException | -10010 | http请求返回5xx | |
KSYMPErrorCodeInvalidData | -10011 | 无效的媒体数据 | |
KSYMPErrorCodeUnsupportVideoCodec | -10012 | 不支持的视频编码类型 | |
KSYMPErrorCodeUnsupportAudioCodec | -10013 | 不支持的音频编码类型 | |
KSYMPErrorCodeVideoDecodeFailed | -10014 | 视频解码失败 | |
KSYMPErrorCodeAudioDecodeFailed | -10015 | 音频解码失败 | |
KSYMPErrorCode3xxOverFlow | -10016 | 多次3xx跳转 | |
KSYMPErrorInvalidURL | -10050 | 无效的url | v2.1.0+ |
KSYMPErrorNetworkUnReachable | -10051 | 网络不通 | v2.1.1 |
也可以通过参考API文档中KSYMPErrorCode定义
-
当接收到MPMoviePlayerPlaybackDidFinishNotification通知时,可通过userInfo字典中关键字MPMoviePlayerPlaybackDidFinishReasonUserInfoKey查询具体的结束原因。当结束原因为MPMovieFinishReasonPlaybackError时,userInfo字典中的关键字error指明了具体的错误码。
-
如果开启了网络连通性的探测,那在断网的情况下调用prepareToPlay方法,SDK上报的错误码为KSYMPErrorNetworkUnReachable;否则上报的错误码为KSYMPErrorCodeDNSParseFailed
由于KSYReachability在某些特殊的网络下存在误判的可能性,因此仅v2.1.1版本会上报KSYMPErrorNetworkUnReachable,其他版本依然上报原来的错误码,用户可通过监听MPMoviePlayerNetworkStatusChangeNotification和networkStatus属性来获取当前网络状况
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"];
}
}