GithubHelp home page GithubHelp logo

react-rtc's Introduction

react-rtc

react-rtc is a react component that uses firebase to establish webRTC connections.

Simple demo

Usage

/** @jsx React.DOM */
var Firebase = require('firebase');
var React = require('react');

var Rtc = require('react-rtc');

var myFirebaseRef = new Firebase('https://someFbApp.firebaseio.com');

var VideoComponent = React.createClass({
  componentWillReceiveProps: function(newProps) {
    if (this.props.remoteVideo !== newProps.remoteVideo)
      this.setState({src: URL.createObjectURL(newProps.remoteVideo)});
  },

  render: function() {
    return <video src={this.state.src} />
  }
});

// Then use it like this:

<Rtc id="myId" fb={myFirebaseRef}>
  <VideoComponent key="sharedKey">
  <VideoComponent key="anotherKeySharedWithAnotherClient">
</Rtc>

API

Rtc requires id and fb props. It can also take a component prop which decides what DOM element child components will render in. It will default to a DIV element. id must be unique amongst all clients/browsers who share the same firebase ref.

Child components require a key component. Whenever a child component in another browser has the same key, they will establish a webRTC connection, and the child will get two new props injected: localStream and remoteStream. These are webRTC media streams.

react-rtc's People

Contributors

olavhn avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

chenrui2014

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.