diff --git a/src/components/Icons.js b/src/components/Icons.js new file mode 100644 index 0000000..0092484 --- /dev/null +++ b/src/components/Icons.js @@ -0,0 +1,20 @@ +import React from 'react' +export const ShareScreenIcon = () => ( + +); + +export const MicOnIcon = () => ( + +) + +export const MicOffIcon = () => ( + +) + +export const CamOnIcon = () => ( + +) + +export const CamOffIcon = () => ( + +) diff --git a/src/components/ShareScreenIcon.js b/src/components/ShareScreenIcon.js deleted file mode 100644 index 971564b..0000000 --- a/src/components/ShareScreenIcon.js +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react' -const ShareScreenIcon = () => ( - -) - -export default ShareScreenIcon \ No newline at end of file diff --git a/src/components/video.js b/src/components/video.js index ec58725..cb9310e 100644 --- a/src/components/video.js +++ b/src/components/video.js @@ -3,7 +3,8 @@ import VideoCall from '../helpers/simple-peer'; import '../styles/video.css'; import io from 'socket.io-client'; import { getDisplayStream } from '../helpers/media-access'; -import ShareScreenIcon from './ShareScreenIcon'; +import {ShareScreenIcon,MicOnIcon,MicOffIcon,CamOnIcon,CamOffIcon} from './Icons'; + class Video extends React.Component { constructor() { super(); @@ -15,10 +16,13 @@ class Video extends React.Component { peer: {}, full: false, connecting: false, - waiting: true + waiting: true, + micState:true, + camState:true, }; } videoCall = new VideoCall(); + componentDidMount() { const socket = io(process.env.REACT_APP_SIGNALING_SERVER); const component = this; @@ -27,6 +31,7 @@ class Video extends React.Component { this.getUserMedia().then(() => { socket.emit('join', { roomId: roomId }); }); + socket.on('init', () => { component.setState({ initiator: true }); }); @@ -45,6 +50,8 @@ class Video extends React.Component { component.setState({ full: true }); }); } + + getUserMedia(cb) { return new Promise((resolve, reject) => { navigator.getUserMedia = navigator.getUserMedia = @@ -69,6 +76,29 @@ class Video extends React.Component { ); }); } + + setAudioLocal(){ + if(this.state.localStream.getAudioTracks().length>0){ + this.state.localStream.getAudioTracks().forEach(track => { + track.enabled=!track.enabled; + }); + } + this.setState({ + micState:!this.state.micState + }) + } + + setVideoLocal(){ + if(this.state.localStream.getVideoTracks().length>0){ + this.state.localStream.getVideoTracks().forEach(track => { + track.enabled=!track.enabled; + }); + } + this.setState({ + camState:!this.state.camState + }) + } + getDisplay() { getDisplayStream().then(stream => { stream.oninactive = () => { @@ -82,6 +112,7 @@ class Video extends React.Component { this.state.peer.addStream(stream); }); } + enter = roomId => { this.setState({ connecting: true }); const peer = this.videoCall.init( @@ -105,6 +136,7 @@ class Video extends React.Component { console.log(err); }); }; + call = otherId => { this.videoCall.connect(otherId); }; @@ -132,14 +164,51 @@ class Video extends React.Component { id='remoteVideo' ref={video => (this.remoteVideo = video)} /> + +
Establishing connection...
diff --git a/src/styles/video.css b/src/styles/video.css index 1d1aa82..5dba0ad 100644 --- a/src/styles/video.css +++ b/src/styles/video.css @@ -30,10 +30,15 @@ color: greenyellow; height: 100vh; } -.share-screen-btn{ + +.controls{ position: absolute; bottom: 24px; left: 24px; +} +.control-btn{ + position: relative; + margin-right: 24px; background: transparent; outline: none; border: none; @@ -43,6 +48,7 @@ height: 64px; width: 64px; } + @media screen and (max-width: 480px) { .video-wrapper { position: relative;