Максимальная длительность видеозаписи
Получите или задайте максимальную длительность видеозаписи. SDK использует минуты.
Справочник API
Фреймворк
AIBuds.xcframework
Протокол
- Swift
- Objective-C
/// 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?
)
}/// The protocol for device API that supports camera.
@protocol AIBudsDeviceCameraAPI <AIBudsDeviceAPI>
/// Maximum video recording duration (in minutes) allowed by the device.
@property(nonatomic, readonly, strong) NSNumber *_Nullable maxVideoRecordDuration;
/// 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.
- (void)setMaxVideoRecordDuration:(NSInteger)duration
completion:(AIBudsCompletionHandler _Nullable)completion;
@end| Символ | Назначение |
|---|---|
maxVideoRecordDuration | Текущая максимальная длительность в минутах. |
setMaxVideoRecordDuration | Задать максимальную длительность в минутах. |
Примеры использования
- Swift
- Objective-C
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") }
}id<AIBudsDeviceCameraAPI> device = (id<AIBudsDeviceCameraAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceCameraAPI)]) {
NSLog(@"Current maximum: %@ minutes", device.maxVideoRecordDuration);
[device setMaxVideoRecordDuration:30
completion:^(BOOL success, NSError *_Nullable error) {
if (!success)
NSLog(@"Update failed: %@", error.localizedDescription);
}];
}Текущее Demo использует ползунок 1...120 минут. Открытый SDK не определяет общий диапазон, поэтому считайте эти границы соглашением Demo до появления публичной возможности.