首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SeektoTime不能正常工作

SeektoTime不能正常工作
EN

Stack Overflow用户
提问于 2016-11-12 18:04:03
回答 1查看 180关注 0票数 0

为了暂停和恢复视频,我正在使用下面的代码。但它不是从它离开的地方恢复。有人能帮助我吗?

代码语言:javascript
复制
-(void)appEnteredBackground:(NSNotification*)notification {
    [playerViewController.player pause];
    currentTime = [playerViewController.player currentTime];
}

-(void)appEnteredForeground:(NSNotification*)notification {

    if(playerViewController.player.status == AVPlayerStatusReadyToPlay &&
       self.playerViewController.player.currentItem.status ==  AVPlayerItemStatusReadyToPlay) {
       total_duration = self.playerViewController.player.currentItem.duration;
       [self.playerViewController.player.currentItem seekToTime:CMTimeMakeWithSeconds(CMTimeGetSeconds(currentTime),60000)];
       [playerViewController.player play];
    }
}
EN

回答 1

Stack Overflow用户

发布于 2017-01-08 20:35:31

如果currentTime值保持不变,则需要添加公差部分以从精确秒开始恢复。

代码语言:javascript
复制
[self.playerViewController.player.currentItem seekToTime:CMTimeMakeWithSeconds(CMTimeGetSeconds(currentTime),60000) toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40561713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档