hirbod/react-native-volume-manager

Setting volume on iOS in VoIP Video Call

wilmxre opened this issue · 3 comments

Hello.

Has anyone tried to set the volume of the video call, with this library?
I tried doing it, but with no success. Sometimes it works for a certain amount of time, then stops working completely when the video call screen is in focus again. Sometimes it doesn't even work at all.

I am using react-native-callkeep and react-native-incall-manager to handle my calls, and to route the audio to the speakers, maybe react-native-volume-manager has a conflict when used with those libraries (maybe a specific library has the superior control over the audio session or more permission, overruling the others), i don't know.

When the video call screen is in focus, i call these:

await VolumeManager.setCategory('PlayAndRecord', false);
await VolumeManager.setMode('VideoChat'); // i tried it with VoiceChat and SpokenAudio too
await VolumeManager.setActive(true, true);

Then, when i set the volume of the call:

await VolumeManager.setVolume(volume * 0.2) // volume is [1, 5]

When the video call screen is out of focus/unmounted, i call this, to clean the audio session:

VolumeManager.setActive(false)

Am i doing something wrong? Did anyone implement this use case successfully before?

My environment is:

iPad (9th generation)
iPadOS Version: 16.3.1
Physical device

Dependencies:

"react-native": "0.70.5",
"expo": "~47.0.12",
"react-native-callkeep": "4.3.12",
"react-native-incall-manager": "4.0.1",
"react-native-volume-manager": "1.8.1",

Often, problems occur due to a lost Audio session. In certain circumstances, using VolumeManager.enable(true) may resolve these issues. It is possible that third-party libraries could be terminating the audio session prematurely. Note that the VolumeManager will only operate when there is an active Audio Session.

Okay, would you recommend calling VolumeManager.enable(true) before this?

await VolumeManager.setCategory('PlayAndRecord', false);
await VolumeManager.setMode('VideoChat'); // i tried it with VoiceChat and SpokenAudio too
await VolumeManager.setActive(true, true);

Regrettably, I'm not familiar with the inner workings of the other libraries in question, so some experimentation may be required on your part. I suspect that initiating or terminating a call, or sending the app to the background, might disrupt the audio session. As a result, you may need to re-enable it. The setActive method only toggles the current session's active state, whereas using enable can provide a more comprehensive solution by asserting control at a higher level. It might prove beneficial in this context.

I had similar issue requests in the past and enable seemed to solve it for all of them.

See #21 and #22