1.2.5 • Published 6 years ago

openvidu-hangouts-react v1.2.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Openvidu Hangouts React

OpenviduHangoutsReact is a room videoconference component library for React.

It's written in JavaScript.

To be able to work in the browser, OpenviduReact uses openvidu-browser to communicate with the OpenVidu Server.

To use AngularOpenVidu, WebRTC support is required (Chrome, Firefox, Opera).

Table of contents

App Demo

In this demo you will see a use case of openvidu-hangouts-react, where you can test ALL the features included in this component.

Features

  • Join a group call
  • Close group call
  • Disable camera
  • Mute microphone
  • Toggle fullscreen video
  • Send messages with a chat

Installation

  1. Install openvidu-hangouts-react node module through npm:

npm i openvidu-hangouts-react --save or yarn add openvidu-hangouts-react

  1. Also you have to install some dependencies in order to import material library correctly:

npm i @material-ui/core --save-dev

npm i @material-ui/icons --save-dev

  1. Import OpenviduReact to your App.js and use it in this way:
import React, { Component } from 'react';
import OpenviduReact from '../lib';
import './App.css';
import Card from '@material-ui/core/Card';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import AppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar";
import Typography from "@material-ui/core/Typography";

  class App extends Component {

    constructor(props) {
      super(props);
      this.child = React.createRef();
      this.state = {
        valueSessionId: 'Session A',
        valueUserName: 'Participant' + Math.floor(Math.random() * 100),
        showLogin: true
      }

      this.onClick = this.onClick.bind(this);
      this.updateShowLogin = this.updateShowLogin.bind(this);
    }

    handleChangeSessionId(e){
      this.setState({
        valueSessionId : e.target.value,
      });
    }
  
    handleChangeUserName(e){
      this.setState({
        valueUserName : e.target.value,
      });
    }

    onClick(e) {
      this.child.current.joinSession();
      this.updateShowLogin(e);
    }

    updateShowLogin(e) {
      e.preventDefault();
      this.setState({
        showLogin: !this.state.showLogin
      })
    }

    render () {
      var valueSessionId = this.state.valueSessionId;
      var valueUserName = this.state.valueUserName;
      var valueShowLogin = this.state.showLogin;
      return (
        <div id= "main-container" className="container">
        { valueShowLogin === true ? 
        <div id="join">
          <AppBar position="static" color="primary">
            <Toolbar>
              <Typography variant="title" color="inherit">
                React Openvidu Hangouts 
              </Typography>
            </Toolbar>
          </AppBar>
          <div id="join-dialog" className="jumbotron vertical-center">
          <Card className="card">
              <Typography variant="display1" color="secondary" align="center">
                  Join a video session
              </Typography>
              <form className="form-group" onSubmit={this.handleSubmit}>
              <CardContent className="card-login">
                  <TextField className="form-control" type="text" label="Participant" id="userName" value={valueUserName} onChange={this.handleChangeUserName.bind(this)}required/>
                  <br />
                  <br />
                  <TextField className="form-control" type="text" label="Session" id="sessionId" inputRef={(input) => { this.sessionId = input; }} value={valueSessionId} onChange={this.handleChangeSessionId.bind(this)}required/>
              </CardContent>
              <CardActions className="button-login">
                <Button variant="raised" color="primary" id="join-button" name="commit" onClick={this.onClick}>
                  JOIN
                </Button>
              </CardActions>
          </form>    
          </Card>
          </div>
        </div> : null }
        <div id="videoCallContainer">
          <OpenviduReact updateLogin = {this.updateShowLogin} ref={this.child} wsUrl={"localhost"} sessionId={valueSessionId} participantId={valueUserName}/>
        </div>
        </div>
      );
    }
  }

export default App;
NameTypeOptionalDescription
wsUrlStringrequiredWebsocket URL pointing to your OpenVidu Server
sessionIdStringrequiredAn id for the session you want to join to
participantIdStringrequiredAn id for the current participant joining the session
updateLoginfunctionrequiredFunction to toggle between session states
reffucntionrequiredRefers the child component OpenviduReact in order to init session
  1. Run the following commands to start the app:

    npm install

    npm start

  2. Deploy OpenVidu Server

Follow the instructions in this page to deploy it with docker.

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago