View Volume Capability and Levels
Read the device's volume-setting capability and currently available volume levels.
Prerequisites
- The device is connected and ready.
- The device conforms to
DeviceVolumeControlAPI.
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protocol
- Swift
- Objective-C
/// The protocol for device volume control API.
protocol DeviceVolumeControlAPI: DeviceAPI {
/// The device's volume-set capability.
var volumeSetCapability: VolumeSetCapability { get }
/// Current volumes information of the device, or `nil` if unavailable.
var volumesInfo: VolumesInfoModel? { get }
}/// The protocol for device volume control API.
@protocol AIBudsDeviceVolumeControlAPI <AIBudsDeviceAPI>
/// The device's volume-set capability.
@property(nonatomic, readonly) enum AIBudsVolumeSetCapability volumeSetCapability;
/// Current volumes information of the device, or `nil` if unavailable.
@property(nonatomic, readonly, strong) AIBudsVolumesInfoModel *_Nullable volumesInfo;
@endProperties
| Property | Type | Description |
|---|---|---|
volumeSetCapability | VolumeSetCapability | The volume-setting capability. |
volumesInfo | VolumesInfoModel? | Current volume values, or nil when unavailable. |
Capability Values
| Value | Meaning in the current SDK |
|---|---|
.none | Volume setting is unavailable. |
.common | System-prompt, media, and in-call channels can be set. |
.advanced | The current snapshot can also report local-playback volume; no public local-playback setter is currently available. |
Volume Information
| Property | Type | Range | Description |
|---|---|---|---|
systemPromptVolume | NSNumber? | 0–100 | Current system-prompt volume. |
mediaVolume | NSNumber? | 0–100 | Current media-playback volume. |
callVolume | NSNumber? | 0–100 | Current in-call volume. |
localPlaybackVolume | NSNumber? | 0–100 | Current local-playback volume; read-only through the current public API. |
Usage Examples
- Swift
- Objective-C
import AIBuds
guard let device = device as? DeviceVolumeControlAPI else {
print("Device does not support volume control")
return
}
print("Capability: \(device.volumeSetCapability)")
if let volumes = device.volumesInfo {
print("System prompt: \(volumes.systemPromptVolume?.intValue.description ?? "Unavailable")")
print("Media: \(volumes.mediaVolume?.intValue.description ?? "Unavailable")")
print("Call: \(volumes.callVolume?.intValue.description ?? "Unavailable")")
print("Local playback: \(volumes.localPlaybackVolume?.intValue.description ?? "Unavailable")")
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDeviceVolumeControlAPI> device = (id<AIBudsDeviceVolumeControlAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceVolumeControlAPI)]) {
AIBudsVolumesInfoModel *volumes = device.volumesInfo;
NSLog(@"System prompt: %@", volumes.systemPromptVolume);
NSLog(@"Media: %@", volumes.mediaVolume);
NSLog(@"Call: %@", volumes.callVolume);
NSLog(@"Local playback: %@", volumes.localPlaybackVolume);
}Error Handling
These properties have no completion handler. Handle unsupported protocol conformance, a nil model, and individual nil channel values without inventing defaults.
Best Practices
- Keep Optional Values Optional: Do not present
nilas zero. - Use Capability for UI Decisions: Hide all write controls for
.none. - Observe Updates: Refresh from the
didVolumesChangeddelegate callback when live values are required.
Notes
- The SDK exposes synchronous properties rather than
getVolumeControlSupportor aResult-based query. - Local-playback volume is currently readable but not independently writable.