Skip to main content

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

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

Properties

PropertyTypeDescription
volumeSetCapabilityVolumeSetCapabilityThe volume-setting capability.
volumesInfoVolumesInfoModel?Current volume values, or nil when unavailable.

Capability Values

ValueMeaning in the current SDK
.noneVolume setting is unavailable.
.commonSystem-prompt, media, and in-call channels can be set.
.advancedThe current snapshot can also report local-playback volume; no public local-playback setter is currently available.

Volume Information

PropertyTypeRangeDescription
systemPromptVolumeNSNumber?0–100Current system-prompt volume.
mediaVolumeNSNumber?0–100Current media-playback volume.
callVolumeNSNumber?0–100Current in-call volume.
localPlaybackVolumeNSNumber?0–100Current 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")")
}

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.