मुख्य कंटेंट तक स्किप करें

अधिकतम रिकॉर्डिंग अवधि

Connected device द्वारा allowed अधिकतम audio recording अवधि पढ़ें या set करें। SDK इसे मिनटों में देता है।

आवश्यक शर्तें

  • डिवाइस connected और ready है।
  • डिवाइस DeviceAudioRecordingAPI को conform करता है।
  • Existing value दिखाने से पहले maxAudioRecordDuration nil नहीं है।

API संदर्भ

Framework

AIBuds.xcframework

Import

Swift
import AIBuds

प्रोटोकॉल

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

प्रॉपर्टी और इंस्टेंस मेथड

Symbolउपयोग
maxAudioRecordDurationCurrent maximum duration मिनटों में; unavailable होने पर nil
setMaxAudioRecordDurationअधिकतम अवधि मिनटों में set करें।

Current SDK Demo 1...120 minute slider उपयोग करता है। Public SDK अभी universal legal range तय नहीं करता, इसलिए इन limits को current Demo convention मानें।

उपयोग के उदाहरण

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

त्रुटि प्रबंधन

Update fail हो तो displayed value maxAudioRecordDuration से restore करें। SDK अभी supported duration range publish नहीं करता, इसलिए Demo range को isolated रखें और public device capability मिलने पर बदलें।