अधिकतम रिकॉर्डिंग अवधि
Connected device द्वारा allowed अधिकतम audio recording अवधि पढ़ें या set करें। SDK इसे मिनटों में देता है।
आवश्यक शर्तें
- डिवाइस connected और ready है।
- डिवाइस
DeviceAudioRecordingAPIको conform करता है। - Existing value दिखाने से पहले
maxAudioRecordDurationnilनहीं है।
API संदर्भ
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>प्रोटोकॉल
- Swift
- Objective-C
/// The protocol for device API that supports audio recording.
protocol DeviceAudioRecordingAPI: DeviceAPI {
/// Maximum audio recording duration (in minutes) allowed by the device.
var maxAudioRecordDuration: NSNumber? { get }
/// Sets the maximum audio recording duration (in minutes) allowed by the device.
/// - Parameters:
/// - duration: The desired 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 setMaxAudioRecordDuration(
_ duration: Int,
completion: AIBudsCompletionHandler?
)
}/// The protocol for device API that supports audio recording.
@protocol AIBudsDeviceAudioRecordingAPI <AIBudsDeviceAPI>
/// Maximum audio recording duration (in minutes) allowed by the device.
@property(nonatomic, readonly, strong) NSNumber *_Nullable maxAudioRecordDuration;
/// Sets the maximum audio recording duration (in minutes) allowed by the device.
/// - Parameters:
/// - duration: The desired 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)setMaxAudioRecordDuration:(NSInteger)duration
completion:(AIBudsCompletionHandler _Nullable)completion;
@endप्रॉपर्टी और इंस्टेंस मेथड
| Symbol | उपयोग |
|---|---|
maxAudioRecordDuration | Current maximum duration मिनटों में; unavailable होने पर nil। |
setMaxAudioRecordDuration | अधिकतम अवधि मिनटों में set करें। |
Current SDK Demo 1...120 minute slider उपयोग करता है। Public SDK अभी universal legal range तय नहीं करता, इसलिए इन limits को current Demo convention मानें।
उपयोग के उदाहरण
- Swift
- Objective-C
import AIBuds
guard let device = device as? DeviceAudioRecordingAPI else {
print("Device does not support audio recording")
return
}
if let minutes = device.maxAudioRecordDuration?.intValue {
print("Current maximum: \(minutes) minutes")
}
// 30 minutes follows the range used by the current SDK Demo.
device.setMaxAudioRecordDuration(30) { success, error in
if !success {
print(error?.localizedDescription ?? "Failed to update the duration")
}
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDeviceAudioRecordingAPI> device = (id<AIBudsDeviceAudioRecordingAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceAudioRecordingAPI)]) {
NSLog(@"Current maximum: %@ minutes", device.maxAudioRecordDuration);
// 30 minutes follows the range used by the current SDK Demo.
[device setMaxAudioRecordDuration:30
completion:^(BOOL success, NSError *_Nullable error) {
if (!success) {
NSLog(@"Failed to update the duration: %@",
error.localizedDescription);
}
}];
}त्रुटि प्रबंधन
Update fail हो तो displayed value maxAudioRecordDuration से restore करें। SDK अभी supported duration range publish नहीं करता, इसलिए Demo range को isolated रखें और public device capability मिलने पर बदलें।