美文网首页
[AVPlayerItem seekToTime:toleran

[AVPlayerItem seekToTime:toleran

作者: lucky_life | 来源:发表于2019-09-16 18:18 被阅读0次

    上周游戏新版本发布,新版本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];
    }
    

    记录一下,防止下次踩坑

    相关文章

      网友评论

          本文标题:[AVPlayerItem seekToTime:toleran

          本文链接:https://www.haomeiwen.com/subject/dsrfuctx.html