swift和CMTimeMake

时间:2014-06-25 11:30:35

标签: ios swift cmtime

我尝试捕捉视频:
https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/04_MediaCapture.html#//apple_ref/doc/uid/TP40010188-CH5-SW26

var maxDuration : CMTime = CMTimeMake(seconds, preferredTimeScale)
aMovieFileOutput.maxRecordedDuration = CMTimeMake(seconds, preferredTimeScale)

1行有错误:使用模块' CMTime'作为一种类型 2行有错误:使用未解析的标识符' CMTimeMake'

我做错了什么?

1 个答案:

答案 0 :(得分:21)

CMTimeCMTimeMake在" CoreMedia"中定义。模块,因此你必须

import CoreMedia

然后编译没有问题:

let seconds : Int64 = 10
let preferredTimeScale : Int32 = 1
let aMovieFileOutput = AVCaptureMovieFileOutput()
let maxDuration : CMTime = CMTimeMake(seconds, preferredTimeScale)
aMovieFileOutput.maxRecordedDuration = maxDuration

Swift 3的更新:

let maxDuration = CMTime(seconds: Double(seconds), preferredTimescale: 1)