-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio route to speaker for Android platform #295
Audio route to speaker for Android platform #295
Conversation
What else can we do to get this merged in @manuquentin? Seems purely additive. |
index.js
Outdated
@@ -149,6 +149,8 @@ class RNCallKeep { | |||
|
|||
sendDTMF = (uuid, key) => RNCallKeepModule.sendDTMF(uuid, key); | |||
|
|||
toggleAudioRouteSpeaker = (uuid, useSpeaker) => RNCallKeepModule.toggleAudioRouteSpeaker(uuid, useSpeaker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check to only call it on Android please ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, let me make this Android-specific function
Thanks @vtn-dev-prithipal I've made some comments in your code. Can you please check them ? |
@jpotts18 I havent looked at it properly yet.... but the first thing I can see is theres no if iOS check on the JS api - right now, it would error out in ios. I'm not even 100% sure this should be in here. For example... I use the react-native-call-manager package and I'm able to control the UI routing using that.... I don't see why this module should get involved with it.... what if I use an external module to control the audio session etc? I'm not saying no to the PR, I just need to understand it better |
Hi Dan, But here, it seem to work directly on the |
Yeah... @manuquentin I'm unsure why interacting on the voice connection directly is needed.... I don't want to say this shouldn't get merged.... but I'd argue to the docs need to be super clear why you'd use it here vs using say in-call-manager |
-- Scenario: Whenever the user answer the calls and the app receives an answer event |
@vtn-dev-prithipal does a similar thing need to be done for muting? In my app I use Edit: Nevermind - I just noticed that there already is |
I've tested this PR and it works well when using |
@ReactMethod | ||
public void toggleAudioRouteSpeaker(String uuid, boolean useSpeaker) { | ||
VoiceConnection conn = (VoiceConnection) VoiceConnectionService.getConnection(uuid); | ||
if (conn == null) { | ||
return; | ||
} | ||
if(useSpeaker){ | ||
conn.setAudioRoute(CallAudioState.ROUTE_SPEAKER); | ||
}else{ | ||
conn.setAudioRoute(CallAudioState.ROUTE_EARPIECE); | ||
} | ||
} | ||
|
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
index.d.ts
Outdated
/** | ||
* @description toggleAudioRouteSpeaker method is available only on Android. | ||
*/ | ||
static toggleAudioRouteSpeaker(uuid: string, useSpeaker: boolean) { | ||
|
||
} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
index.js
Outdated
@@ -149,6 +149,8 @@ class RNCallKeep { | |||
|
|||
sendDTMF = (uuid, key) => RNCallKeepModule.sendDTMF(uuid, key); | |||
|
|||
toggleAudioRouteSpeaker = (uuid, useSpeaker) => RNCallKeepModule.toggleAudioRouteSpeaker(uuid, useSpeaker); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
…-native-callkeep into speakerOutputAndroid
1. Indentation issue 2. platform specific-check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per suggestion, changes are updated
@manuquentin is this any closer to being merged? I've been using it for a while in my app via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, please add documentation and we'll merge it.
I'm happy to add some documentation if @vtn-dev-prithipal is unable to? |
yes, please. I have added few lines. @grit96 please review and make changes if necessary. |
/** | ||
* @description when Phone call is active, Android control the audio service via connection service. so this function help to toggle the audio to Speaker or wired/ear-piece or vice-versa | ||
* @param {*} uuid | ||
* @param {*} routeSpeaker | ||
* @returns Audio route state of audio service | ||
*/ |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated here b0a2fda
please review
Co-authored-by: Geraint White <geraintwhite@gmail.com>
Thank you! |
@manuquentin please review and merge it if everything is correct. |
Co-authored-by: Geraint White <geraintwhite@gmail.com>
Co-authored-by: Geraint White <geraintwhite@gmail.com>
if (conn == null) { | ||
return; | ||
} | ||
if(useSpeaker){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be routeSpeaker
here.
Can you please also reformat code and add space before (
and after )
.
Same for the else below, space before {
and after }
.
1. param routeSpeaker updated . 2. reformated code
Thanks @ vtn-dev-prithipal |
Added a function that routes audio to the speaker for the Android platform
Issue: When Callkeep Active Call UI and custom Call UI are active simultaneously and the user tries to route the audio to the speaker from the earpiece or vice-versa from the custom call screen. The android connection service doesn't release the audio manager and the application is unable to change the state via the audio manager.