Ana içeriğe geç

Video Kaydetme

Bağlı cihazdan video kaydını başlatmasını veya durdurmasını isteyin.

Ön Koşullar

  • Cihaz bağlıdır, yeterli depolama alanı vardır ve DeviceCameraAPI protokolüne uyar.

API Referansı

Protokol

Swift
/// The protocol for device API that supports camera.
protocol DeviceCameraAPI: DeviceAPI {
    /// Requests to start video recording.
    /// - Parameters:
    ///   - completion: A closure that is called when the operation completes.
    ///     - success: `true` if the operation was successful; otherwise `false`.
    ///     - statusCode: The status code returned by the device. `nil` if the operation failed.
    ///     - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
    func requestVideoRecording(_ completion: AIBudsStatusCodeCompletionHandler?)

    /// Requests to stop the current video recording session.
    /// - Parameters:
    ///   - completion: A closure that is called when the operation completes.
    ///     - success: `true` if the operation was successful; otherwise `false`.
    ///     - statusCode: The status code returned by the device. `nil` if the operation failed.
    ///     - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
    func requestStopVideoRecording(_ completion: AIBudsStatusCodeCompletionHandler?)
}
YöntemAmaç
requestVideoRecordingVideo kaydını başlatır.
requestStopVideoRecordingVideo kaydını durdurur.

Kullanım Örnekleri

Swift
guard let device = device as? DeviceCameraAPI else { return }

device.requestVideoRecording { success, statusCode, error in
    guard success else {
        print(error?.localizedDescription ?? "Video recording failed to start")
        return
    }
    print("Video recording started: \(statusCode?.stringValue ?? "Unavailable")")
}

device.requestStopVideoRecording { success, _, error in
    if !success { print(error?.localizedDescription ?? "Video recording failed to stop") }
}

Callback'ler cihaz komut durumunu bildirir; video yolu veya çözünürlük döndürmez. Güncel genel API istek bazında çözünürlük seçimi sunmaz.