跳到主要内容

最大录像时长

读取或设置最大录像时长。SDK 以分钟表示该值。

API 参考

框架

AIBuds.xcframework

协议

Swift
/// The protocol for device API that supports camera.
protocol DeviceCameraAPI: DeviceAPI {
    /// Maximum video recording duration (in minutes) allowed by the device.
    var maxVideoRecordDuration: NSNumber? { get }

    /// Sets the maximum video recording duration.
    /// - Parameters:
    ///   - duration: The maximum recording duration in minutes.
    ///   - completion: A closure that is called when the operation completes.
    ///     - success: `true` if the operation was successful; otherwise `false`.
    ///     - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
    func setMaxVideoRecordDuration(
        _ duration: Int,
        completion: AIBudsCompletionHandler?
    )
}
符号用途
maxVideoRecordDuration当前最大时长,单位为分钟。
setMaxVideoRecordDuration设置最大时长,单位为分钟。

使用示例

Swift
guard let device = device as? DeviceCameraAPI else { return }
print(
    "Current maximum: \(device.maxVideoRecordDuration?.intValue.description ?? "Unavailable") minutes"
)

device.setMaxVideoRecordDuration(30) { success, error in
    if !success { print(error?.localizedDescription ?? "Update failed") }
}

当前 Demo 使用 1...120 分钟滑块。公开 SDK 未说明统一范围,因此在公开能力提供前,应将该限制视为 Demo 约定。