上周游戏新版本发布,新版本iOS提交上去,过审释放之后,看了一下bugly,一大片[AVPlayerItem seekToTime:toleranceBefore:toleranceAfter:completionHandler:] Seeking is not possible to time {INVALID}错误,经过查找答案之后,找出原因:
[self.moviePlayer seekToTime:_curTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:^(BOOL finished) {
if (finished) {
[self.moviePlayer play];
}
}];
原来这段代码在切后台回到前端的时候是有可能出现异常的。后修改如下:
@try
{
if (CMTIME_IS_VALID(_curTime))
{
[self.moviePlayer seekToTime:_curTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:^(BOOL finished) {
if (finished) {
[self.moviePlayer play];
}
}];
}else{
[self.moviePlayer play];
}
}
@catch (NSException * exception) {
[self.moviePlayer play];
}
记录一下,防止下次踩坑
网友评论