3.1.6 • Published 7 years ago

the-peer v3.1.6

Weekly downloads
35
License
MIT
Repository
github
Last release
7 years ago

the-peer

Build Status npm Version JS Standard

Peer video chat component

Installation

$ npm install the-peer --save

Usage

'use strict'

import React from 'react'
import { ThePeerSender, ThePeerReceiver, ThePeerStyle } from 'the-peer'
import { TheButton, TheButtonStyle } from 'the-button'
import { TheVideoStyle } from 'the-video'

class ExampleComponent extends React.PureComponent {
  constructor (props) {
    super(props)
    const s = this
    s.state = {
      peerId: 'hoge12345',
      ready: false,
      audioEnabled: true,
      videoEnabled: true
    }
  }

  render () {
    const s = this
    const {state} = s
    const peerOptions = {
      port: 9000,
      host: 'localhost',
      debug: 3
    }
    const {
      ready,
      peerId,
      audioEnabled,
      videoEnabled
    } = state
    return (
      <div>
        <ThePeerStyle/>
        <TheButtonStyle/>
        <TheVideoStyle/>

        <fieldset>
          <legend>Sender</legend>
          <div>
            <ThePeerSender {...{peerId, peerOptions, audioEnabled, videoEnabled}}
                           onReady={() => s.setState({ready: true})}
                           label='This is Me'
            />
          </div>
          <TheButton onClick={() => s.setState({peerId: 'hoge1234'})}>Start</TheButton>
          <TheButton onClick={() => s.setState({peerId: null})}>Stop</TheButton>
          <TheButton onClick={() => s.setState({audioEnabled: !s.state.audioEnabled})}>Toggle audio</TheButton>
          <TheButton onClick={() => s.setState({videoEnabled: !s.state.videoEnabled})}>Toggle video</TheButton>
        </fieldset>
        <br/>
        <fieldset>
          <legend>Receiver</legend>
          <div>
            {
              ready && (
                <div>
                  <ThePeerReceiver {...{peerId, peerOptions}}
                                   label='Some One Else'
                  />
                  <ThePeerReceiver {...{peerId, peerOptions}}
                  />
                </div>
              )
            }
          </div>
        </fieldset>
      </div>

    )
  }
}

export default ExampleComponent

Components

ThePeerReceiver

Peer video chat component

Props

NameTypeDescriptionDefault
peerIdstringId for peernull
peerOptionsobjectPeer js options{}
volumenumberVolume0.9
widthnumberComponent width150
heightnumberComponent height150
reloadableboolReloadable on clickfalse
onErrorfuncHandler for error eventsnull
labelstringLabel textnull
labelBaseColorBASE_LABEL_COLOR

ThePeerSender

Peer video chat component

Props

NameTypeDescriptionDefault
peerIdstringId for peernull
peerOptionsobjectPeer js options{}
volumenumberVolume0.9
videoEnabledboolEnable videotrue
audioEnabledboolDisable videofalse
widthnumberComponent width150
heightnumberComponent height150
reloadableboolReloadable on clickfalse
onReadyfuncHandler for peer readynull
onConnectionfuncHandler for connectionnull
onConnectionClosefuncHandler for connectionClosenull
onErrorfuncHandler for error eventsnull
labelstringLabel textnull
videoSize{width: {ideal: 640, height: {ideal: 360}}}
labelBaseColorBASE_LABEL_COLOR

ThePeerStyle

Style for ThePeer

Props

NameTypeDescriptionDefault
optionsobjectStyle options{}

License

This software is released under the MIT License.

Links

3.1.6

7 years ago

3.1.5

7 years ago

3.1.4

7 years ago

3.1.3

7 years ago

3.1.2

7 years ago

3.1.1

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.2.0

7 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago