Skip to content

Core Volume Control Get Support

Mr.P edited this page Aug 29, 2026 · 2 revisions

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

import AIBuds

Objective-C

#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>

Protocol

Swift

/// 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 }
}

Objective-C

/// 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;
@end

Properties

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

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

Objective-C

#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

  1. Keep Optional Values Optional: Do not present nil as zero.
  2. Use Capability for UI Decisions: Hide all write controls for .none.
  3. Observe Updates: Refresh from the didVolumesChanged delegate callback when live values are required.

Notes

  • The SDK exposes synchronous properties rather than getVolumeControlSupport or a Result-based query.
  • Local-playback volume is currently readable but not independently writable.

AIBuds SDK iOS Wiki

Clone this wiki locally