メインコンテンツまでスキップ

録音時間の上限

接続中のデバイスで許可される音声録音時間の上限を確認または設定します。値の単位は分です。

前提条件

  • デバイスが接続済みで、操作可能な状態であること。
  • デバイスが DeviceAudioRecordingAPI に準拠していること。
  • 現在値を表示する前に、maxAudioRecordDurationnil ではないことを確認すること。

API リファレンス

フレームワーク

AIBuds.xcframework

インポート

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

プロパティとインスタンスメソッド

シンボル用途
maxAudioRecordDuration現在の上限(分)。取得できない場合は nil
setMaxAudioRecordDuration録音時間の上限を分単位で設定します。

現在の SDK Demo では 1...120 分のスライダーを使用しています。公開 SDK では共通の有効範囲がまだ明記されていないため、この範囲は現行 Demo の仕様として扱ってください。

使用例

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

エラー処理

更新に失敗した場合は、maxAudioRecordDuration から表示値を復元します。SDK は現在、対応する時間範囲を公開していません。Demo の範囲は独立して管理し、公開デバイス機能として範囲を取得できるようになった時点で置き換えてください。