Skip to content

Commit

Permalink
Audio route to speaker for Android platform
Browse files Browse the repository at this point in the history
  • Loading branch information
vtn-dev-prithipal committed Sep 24, 2020
1 parent 698f795 commit be5f3fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,19 @@ public void setMutedCall(String uuid, boolean shouldMute) {
conn.onCallAudioStateChanged(newAudioState);
}

@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);
}
}

@ReactMethod
public void sendDTMF(String uuid, String key) {
Connection conn = VoiceConnectionService.getConnection(uuid);
Expand Down
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ declare module 'react-native-callkeep' {
* @description setMutedCall method is available only on iOS.
*/
static setMutedCall(uuid: string, muted: boolean): void
/**
* @description toggleAudioRouteSpeaker method is available only on Android.
*/
static toggleAudioRouteSpeaker(uuid: string, useSpeaker: boolean) {

}
static setOnHold(uuid: string, held: boolean): void

/**
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class RNCallKeep {

sendDTMF = (uuid, key) => RNCallKeepModule.sendDTMF(uuid, key);

toggleAudioRouteSpeaker = (uuid, useSpeaker) => RNCallKeepModule.toggleAudioRouteSpeaker(uuid, useSpeaker);

checkIfBusy = () =>
isIOS
? RNCallKeepModule.checkIfBusy()
Expand Down

0 comments on commit be5f3fb

Please sign in to comment.