동영상 녹화
연결된 기기에 동영상 녹화 시작 또는 중지를 요청합니다.
사전 요구 사항
- 기기가 연결되어 있고 저장 공간이 충분하며
DeviceCameraAPI를 준수합니다.
API 참고
프로토콜
- Swift
- Objective-C
/// 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?)
}/// The protocol for device API that supports camera.
@protocol AIBudsDeviceCameraAPI <AIBudsDeviceAPI>
/// 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.
- (void)requestVideoRecordingWithCompletion:(AIBudsStatusCodeCompletionHandler _Nullable)completion;
/// 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.
- (void)requestStopVideoRecordingWithCompletion:
(AIBudsStatusCodeCompletionHandler _Nullable)completion;
@end| 메서드 | 용도 |
|---|---|
requestVideoRecording | 동영상 녹화를 시작합니다. |
requestStopVideoRecording | 동영상 녹화를 중지합니다. |
사용 예제
- Swift
- Objective-C
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") }
}id<AIBudsDeviceCameraAPI> device = (id<AIBudsDeviceCameraAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceCameraAPI)]) {
[device requestVideoRecordingWithCompletion:^(
BOOL success, NSNumber *_Nullable statusCode, NSError *_Nullable error) {
if (!success)
NSLog(@"Start failed: %@", error.localizedDescription);
}];
[device requestStopVideoRecordingWithCompletion:^(
BOOL success, NSNumber *_Nullable statusCode, NSError *_Nullable error) {
if (!success)
NSLog(@"Stop failed: %@", error.localizedDescription);
}];
}콜백은 기기 명령 상태를 보고하며 동영상 경로나 해상도를 반환하지 않습니다. 현재 공개 API는 요청별 해상도 선택 기능을 제공하지 않습니다.