Ana içeriğe geç

Azami Kayıt Süresi

Bağlı aygıtın izin verdiği azami ses kaydı süresini okuyun veya ayarlayın. SDK bu değeri dakika cinsinden ifade eder.

Ön Koşullar​

  • Aygıt bağlı ve hazırdır.
  • Aygıt DeviceAudioRecordingAPI protokolüne uyar.
  • Mevcut değeri göstermeden önce maxAudioRecordDuration nil değildir.

API Reference​

Framework​

AIBuds.xcframework

Import​

Swift
import AIBuds

Protokol​

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

Özellik ve Örnek Yöntemi​

SembolAmaç
maxAudioRecordDurationDakika cinsinden geçerli azami süre; kullanılamıyorsa nil.
setMaxAudioRecordDurationAzami süreyi dakika cinsinden ayarlar.

Mevcut SDK Demo'su 1...120 dakikalık kaydırıcı kullanır. Genel SDK henüz evrensel geçerli aralığı belgelemediğinden bu sınırları Demo'nun geçerli kuralı olarak değerlendirin.

Kullanım Örnekleri​

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

Hata Yönetimi​

Güncelleme başarısız olursa gösterilen değeri maxAudioRecordDuration üzerinden geri yükleyin. SDK desteklenen süre aralığını henüz yayımlamadığından Demo aralığını ayrı tutun ve genel aygıt yeteneği sunulduğunda değiştirin.