let vidWidth = asset?.naturalSize()?.width
let vidHeight = asset?.naturalSize()?.height
我得到:
Type of expression is ambiguous without a type annotation
如何正确执行此操作?
我尝试过的:
let vidWidth: CGFloat = asset?.naturalSize()?.width
let vidHeight: CGFloat = asset?.naturalSize()?.height
但我仍然遇到同样的错误
如Here所述,
naturalSize
已从AVAsset中弃用,您需要使用load(.naturalSize)
的
AVAssetTrack
Task {
do {
let asset:AVAssetTrack? = nil // For testing purposes
let vidHeight = try await asset?.load(.naturalSize).width
}
catch {
print(error)
}
}