[英]Check if CMTime is in CMTimeRange
I'm trying to understand what is the correct way to check if CMTime
is in range. 我试图了解什么是检查
CMTime
是否在范围内的正确方法。 Example: 例:
let's assume we have a video, with a duration of 20 seconds. 假设我们有一个视频,时长为20秒。 We split this video into two
CMTimeRange
. 我们将此视频分为两个
CMTimeRange
。
Now, for any given CMTime
(for example, the video progress). 现在,对于任何给定的
CMTime
(例如,视频进度)。 How can I determine in which CMTimeRange
a CMTime
Exists? 如何确定
CMTime
存在于哪个CMTimeRange
?
CMTimeRange
has a CMTimeRange
有一个
func containsTime(_ time: CMTime) -> Bool
method, so you can simply check 方法,因此您只需检查一下
if range.containsTime(time) {
// ...
}
Remark: The documentation seems to be outdated, the global function CMTimeRangeContainsTime()
is imported as a member function to Swift. 备注: 文档似乎已过时,全局函数
CMTimeRangeContainsTime()
作为成员函数导入到Swift。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.