在AVPlayer seekToTime中使用秒 [英] Using seconds in AVPlayer seekToTime
问题描述
这应该很简单.我有一个AVPlayer
播放视频文件,我希望能够跳到特定时间,但是在理解CMTime
的工作方式时遇到了一些麻烦.
this should be a simple one. I have an AVPlayer
playing a video file and I want to be able to jump to a specific time but I'm having some trouble understanding how CMTime
works.
我需要指定时间(以秒为单位).例如:如果我想跳到第二个10.8,我想做这样的事情:
I need to specify the time in seconds. For example: if I wanted to jump to second 10.8 I'd like to do something like this:
[self.avPlayer.currentItem seekToTime:CMTimeMakeWithSeconds(10.8, 1];
但是我没有得到想要的结果.
But I'm not getting the result I want.
推荐答案
http://warrenmoore.net/understanding- cmtime
可能会让您更清楚地了解CMTime.
Might give you a clearer idea of CMTime.
如果您将行更改为读取...
If you changed your line to read...
[self.avPlayer.currentItem seekToTime:CMTimeMakeWithSeconds(10.8, 60000)];
您可能会获得更好的结果. 60000是一秒内构成多少个项目.如果将1用作该值,则每秒只能跳到一个位置-通过放置60000,您将在10秒和11秒之间给自己60000个位置.
You might get better results. The 60000 is how many items make up a single second. If you use 1 for this value then you can only jump to a single place per second - by putting 60000 you are giving yourself 60000 places between second 10 and second 11.
这篇关于在AVPlayer seekToTime中使用秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!