Ses Düzeyi Yeteneğini ve Değerlerini Görüntüleme
Cihazın ses ayarlama yeteneğini ve o anda kullanılabilen ses düzeylerini okuyun.
Ön Koşullar
- Cihaz bağlı ve hazırdır.
- Cihaz
DeviceVolumeControlAPIprotokolüne uyar.
API Referansı
Framework
AIBuds.xcframework
İçe Aktarma
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protokol
- 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;
@endÖzellikler
| Özellik | Tür | Açıklama |
|---|---|---|
volumeSetCapability | VolumeSetCapability | Ses düzeyi ayarlama yeteneği. |
volumesInfo | VolumesInfoModel? | Güncel ses düzeyleri; kullanılamıyorsa nil. |
Yetenek Değerleri
| Değer | Güncel SDK'daki anlamı |
|---|---|
.none | Ses düzeyi ayarlanamaz. |
.common | Sistem bildirimi, medya ve görüşme kanalları ayarlanabilir. |
.advanced | Güncel durum yerel oynatma sesini de bildirebilir; şu anda bunu ayarlayan genel bir API yoktur. |
Ses Düzeyi Bilgileri
| Özellik | Tür | Aralık | Açıklama |
|---|---|---|---|
systemPromptVolume | NSNumber? | 0–100 | Güncel sistem bildirimi ses düzeyi. |
mediaVolume | NSNumber? | 0–100 | Güncel medya oynatma ses düzeyi. |
callVolume | NSNumber? | 0–100 | Güncel görüşme ses düzeyi. |
localPlaybackVolume | NSNumber? | 0–100 | Güncel yerel oynatma ses düzeyi; mevcut genel API'de salt okunurdur. |
Kullanım Örnekleri
- 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);
}Hata Yönetimi
Bu özelliklerin completion handler'ı yoktur. Desteklenmeyen protokolü, nil modeli ve ayrı nil kanal değerlerini varsayılan değer uydurmadan işleyin.
En İyi Uygulamalar
- İsteğe Bağlı Değerleri Koruyun:
nildeğerini sıfır olarak göstermeyin. - Arayüz Kararlarında Yeteneği Kullanın:
.noneiçin tüm yazma denetimlerini gizleyin. - Güncellemeleri İzleyin: Canlı değer gerektiğinde
didVolumesChangeddelegate callback'inden yenileyin.
Notlar
- SDK,
getVolumeControlSupportveyaResulttabanlı sorgu yerine eşzamanlı özellikler sunar. - Yerel oynatma ses düzeyi şu anda okunabilir ancak bağımsız olarak yazılamaz.