react-native-volume-manager
react-native-volume-manager copied to clipboard
Feature Request: `VolumeManager.getStatus()` an iOS prop that returns the status of the VolumeManager
I am having a little trouble trying to figure out the proper way to initialize the AudioSession on iOS correctly, so I guess this could be a double feature request:
- Slightly improve docs (or maybe an example) of managing the iOS audio session. Currently here is my function (which could be used in an example -- when corrected of course).
Starting Audio Session:
async function setupAudioSessionIOS(category: AVAudioSessionCategory, mode: AVAudioSessionMode) {
try {
await VolumeManager.enable(true, true) // Which one is better for performance, `async` = true? Is there a reason to not do async?
await VolumeManager.showNativeVolumeUI({ enabled: true })
await VolumeManager.enableInSilenceMode(true)
await VolumeManager.setCategory(category, true)
await VolumeManager.setMode(mode)
await VolumeManager.setActive(true, true) // Which one is better for performance, `async` = true? Is there a reason to not do async?
} catch (error) {
console.error("Audio session setup failed:", error)
}
}
// To tear down the session
export async function terminateAudioSession() {
try {
// Which order do I call enable / setActive in?
await VolumeManager.enable(false, true)
await VolumeManager.setActive(false, true)
await VolumeManager.enableInSilenceMode(false)
} catch (error) {
console.error("Audio session teardown failed:", error)
}
}
- In order for me to de-bug whats going on in the iOS side from the JS side, a function like
VolumeManager.getStatus()that returned an object like:
{
enabled: false
isActive: false
category: null
mode: null
}
would substantially help me in debugging what I'm doing right and wrong I think.
Anyways, you are the ****** man for this library. Thanks @hirbod