-
Notifications
You must be signed in to change notification settings - Fork 0
Core Camera Take Photo
Mr.P edited this page Aug 29, 2026
·
2 revisions
Start a device photo-taking session with a CaptureMode, then stop the session when appropriate.
- The device is connected, has available storage, and conforms to
DeviceCameraAPI.
/// The protocol for device API that supports camera.
protocol DeviceCameraAPI: DeviceAPI {
/// Requests to take a photo with the specified capture mode.
/// - Parameters:
/// - mode: The capture mode for photo taking.
/// - 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 requestPhotoTaking(
withCaptureMode mode: CaptureMode,
completion: AIBudsStatusCodeCompletionHandler?
)
/// Requests to stop the current photo taking 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 requestStopPhotoTaking(_ completion: AIBudsStatusCodeCompletionHandler?)
}/// The protocol for device API that supports camera.
@protocol AIBudsDeviceCameraAPI <AIBudsDeviceAPI>
/// Requests to take a photo with the specified capture mode.
/// - Parameters:
/// - mode: The capture mode for photo taking.
/// - 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)requestPhotoTakingWithCaptureMode:(enum AIBudsCaptureMode)mode
completion:(AIBudsStatusCodeCompletionHandler _Nullable)completion;
/// Requests to stop the current photo taking 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)requestStopPhotoTakingWithCompletion:
(AIBudsStatusCodeCompletionHandler _Nullable)completion;
@end| Method | Purpose |
|---|---|
requestPhotoTaking |
Start photo taking in .camera or .ai mode. |
requestStopPhotoTaking |
Stop the active photo-taking session. |
The callbacks return success, an optional device statusCode, and an optional NSError. They do not return a photo file path.
guard let device = device as? DeviceCameraAPI else { return }
device.requestPhotoTaking(withCaptureMode: .camera) { success, statusCode, error in
guard success else {
print(error?.localizedDescription ?? "Photo request failed")
return
}
print("Photo taking started: \(statusCode?.stringValue ?? "Unavailable")")
}
device.requestStopPhotoTaking { success, _, error in
if !success { print(error?.localizedDescription ?? "Stop failed") }
}id<AIBudsDeviceCameraAPI> device = (id<AIBudsDeviceCameraAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceCameraAPI)]) {
[device requestPhotoTakingWithCaptureMode:AIBudsCaptureModeCamera
completion:^(BOOL success,
NSNumber *_Nullable statusCode,
NSError *_Nullable error) {
if (!success)
NSLog(@"Photo request failed: %@",
error.localizedDescription);
}];
[device requestStopPhotoTakingWithCompletion:^(
BOOL success, NSNumber *_Nullable statusCode, NSError *_Nullable error) {
if (!success)
NSLog(@"Stop failed: %@", error.localizedDescription);
}];
}AIBuds SDK documentation · Full documentation · API Reference
- Introduction
- Getting Started
- Core Concepts
-
Core Features
- Basic Features
- Device Info
- Find Device
- Physical Operations
- Work Mode
- Work Status
- Wear Detection
- Volume Control
- Music Control
- TWS
- Equalizer
- ANC
- Audio
- Camera
- Remote Camera
- File Import
- Teleprompter
- Segment Navigation
- Live Streaming
- Device Applications
- OTA
- Camera OTA
- Service Auth
- AI Services
- Voice Assistant
- Logging
- Advanced Topics
- Releases
- Troubleshooting