Skip to content

Core Audio Max Recording Duration

Mr.P edited this page Aug 25, 2026 · 2 revisions

Maximum Recording Duration

Read or set the maximum audio recording duration allowed by the connected device. The SDK expresses this value in minutes.

Prerequisites

  • The device is connected and ready.
  • The device conforms to DeviceAudioRecordingAPI.
  • maxAudioRecordDuration is not nil before showing an existing value.

API Reference

Framework

AIBuds.xcframework

Import

Swift

import AIBuds

Objective-C

#import <AIBuds/AIBuds.h>
#import <AIBuds/AIBuds-Swift.h>

Protocol

Swift

/// 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?
    )
}

Objective-C

/// 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

Property and Instance Method

Symbol Purpose
maxAudioRecordDuration Current maximum duration in minutes, or nil when unavailable.
setMaxAudioRecordDuration Set the maximum duration in minutes.

The current SDK Demo uses a 1...120 minute slider. The public SDK does not yet document a universal legal range, so treat those limits as the current Demo convention.

Usage Examples

Swift

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")
    }
}

Objective-C

#import <AIBuds/AIBuds.h>
#import <AIBuds/AIBuds-Swift.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);
        }
    }];
}

Error Handling

If the update fails, restore the displayed value from maxAudioRecordDuration. The SDK currently does not publish the supported duration range, so keep the Demo range isolated and replace it when a public device capability becomes available.

AIBuds SDK iOS Wiki

Clone this wiki locally