openvidu-react-native: Added mute unmute speaker

This commit is contained in:
csantosm 2021-04-08 12:47:14 +02:00
parent 64f1cc53ef
commit 0c2e261c51
2 changed files with 20 additions and 2 deletions

View File

@ -12,6 +12,8 @@ import {
Image,
PermissionsAndroid,
} from 'react-native';
import InCallManager from 'react-native-incall-manager';
import axios from 'axios';
import { OpenViduReactNativeAdapter, OpenVidu, RTCView } from 'openvidu-react-native-adapter';
@ -38,7 +40,8 @@ export default class App extends Component<Props> {
mirror: true,
videoSource: undefined,
video: true,
audio: true
audio: true,
speaker: false
};
}
@ -272,6 +275,12 @@ export default class App extends Component<Props> {
this.setState({ video: !this.state.video });
}
muteUnmuteSpeaker() {
InCallManager.setSpeakerphoneOn(!this.state.speaker);
this.setState({ speaker: !this.state.speaker });
}
render() {
return (
<ScrollView>
@ -306,6 +315,14 @@ export default class App extends Component<Props> {
color="#3383FF"
/>
</View>
<View style={styles.button}>
<Button
onLongPress={() => this.muteUnmuteSpeaker()}
onPress={() => this.muteUnmuteSpeaker()}
title={this.state.speaker ? 'Mute Speaker' : 'Unmute Speaker'}
color="#79b21e"
/>
</View>
<View style={styles.button}>
<Button
onLongPress={() => this.muteUnmuteCamera()}

View File

@ -17,7 +17,8 @@
"openvidu-react-native-adapter": "file:openvidu-react-native-adapter-2.17.0.tgz",
"react": "17.0.1",
"react-native": "0.64.0",
"react-native-get-random-values": "1.6.0"
"react-native-get-random-values": "1.6.0",
"react-native-incall-manager": "3.3.0"
},
"devDependencies": {
"@babel/core": "7.13.10",