I am making a video chat app which has to work in a webview of my android application.
So What I want is to set audio and video to true or false depending on java. it means if I clicked to audio call button in ui button I should set video to false and vice versa.
this.getUserMedia = navigator.mediaDevices.getUserMedia({
audio: true,
video: true
})
Here is the full code for the Component containing the above lines.
import React, { Component } from 'react';
import MediaContainer from './MediaContainer'
import CommunicationContainer from './CommunicationContainer'
import { connect } from 'react-redux'
import store from '../store'
import io from 'socket.io-client'
class RoomPage extends Component {
constructor(props) {
super(props);
this.getUserMedia = navigator.mediaDevices.getUserMedia({
audio: true,
video: true
}).catch(e => alert('getUserMedia() error: ' + e.name))
this.socket = io.connect();
}
componentDidMount() {
this.props.addRoom();
}
render(){
return (
<div>
<MediaContainer media={media => this.media = media} socket={this.socket} getUserMedia={this.getUserMedia} />
<CommunicationContainer socket={this.socket} media={this.media} getUserMedia={this.getUserMedia} />
</div>
);
}
}
const mapStateToProps = store => ({rooms: new Set([...store.rooms])});
const mapDispatchToProps = (dispatch, ownProps) => (
{
addRoom: () => store.dispatch({ type: 'ADD_ROOM', room: ownProps.match.params.room })
}
);
export default connect(mapStateToProps, mapDispatchToProps)(RoomPage);
If you can provide me with a sample code please. I am new in React, so please be as explicit as possible.