Skip to content

Commit

Permalink
fix. disableVideo
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrixbirds committed Mar 27, 2019
1 parent 6da8e9a commit 1448fc0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions samples/simpleDemo/components/agora.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type Props = {
clientRole: Number,
onCancel: Function,
uid: Number,
showVideo: boolean,
}

export default class AgoraComponent extends Component<Props> {
Expand All @@ -111,7 +112,7 @@ export default class AgoraComponent extends Component<Props> {
isSpeak: true,
isMute: false,
isCameraTorch: false,
disableVideo: false,
showVideo: true,
hideButton: false,
visible: false,
selectedUid: undefined,
Expand Down Expand Up @@ -234,11 +235,17 @@ export default class AgoraComponent extends Component<Props> {
}

toggleVideo = () => {
const showVideo = !this.state.showVideo
this.setState({
disableVideo: !this.state.videodisableVideo
}, () => {
this.state.disableVideo ? RtcEngine.enableVideo() : RtcEngine.disableVideo()
});
showVideo
})
if (showVideo) {
RtcEngine.enableVideo()
RtcEngine.startPreview()
} else {
RtcEngine.disableVideo()
RtcEngine.stopPreview()
}
}

toggleHideButtons = () => {
Expand All @@ -257,7 +264,7 @@ export default class AgoraComponent extends Component<Props> {
})
}

buttonsView = ({hideButton, isCameraTorch, disableVideo, isMute, isSpeaker}) => {
buttonsView = ({hideButton, isCameraTorch, showVideo, isMute, isSpeaker}) => {
if (!hideButton) {
return (
<View>
Expand All @@ -275,7 +282,7 @@ export default class AgoraComponent extends Component<Props> {
/>
<OperateButton
onPress={this.toggleVideo}
source={disableVideo ? EnableCamera() : DisableCamera()}
source={showVideo ? EnableCamera() : DisableCamera()}
/>
</View>
<View style={styles.bottomView}>
Expand Down Expand Up @@ -353,7 +360,7 @@ export default class AgoraComponent extends Component<Props> {
onPress={this.toggleHideButtons}
style={styles.container}
>
<AgoraView style={styles.localView} showLocalVideo={true} />
{ this.state.showVideo ? <AgoraView style={styles.localView} showLocalVideo={this.state.showVideo} /> : null}
<View style={styles.absView}>
<Text>channelName: {this.props.channelName}, peers: {this.state.peerIds.length}</Text>
{this.agoraPeerViews(this.state)}
Expand Down

0 comments on commit 1448fc0

Please sign in to comment.