Skip to main content

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

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

Property and Instance Method​

SymbolPurpose
maxAudioRecordDurationCurrent maximum duration in minutes, or nil when unavailable.
setMaxAudioRecordDurationSet 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")
    }
}

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.