2.0.4 • Published 9 years ago
apeman-react-peer v2.0.4
apeman-react-peer
apeman react package for peer components
Installation
$ npm install apeman-react-peer --saveDemo
Live demo is hosted on GitHub Pages.
Usage
'use strict'
import React from 'react'
import ApPeerCamera from '../../lib/ap_peer_camera'
import ApPeerScreen from '../../lib/ap_peer_screen'
import {
ApButton
} from 'apeman-react-basic'
const Demo = React.createClass({
getInitialState () {
return {
streaming: false
}
},
render () {
const s = this
let { state } = s
return (
<div>
<fieldset>
<legend>Video</legend>
<ApPeerCamera peerId="demo-peer-01"
peerOptions={
{
key:'___your_key___'
}
}
peerEnabled={state.streaming}
onError={(err) => console.error(err)}
/>
<ApButton onTap={s._startStreaming}>Start</ApButton>
<ApButton onTap={s._stopStreaming}>Stop</ApButton>
</fieldset>
<fieldset>
<legend>Camera</legend>
<ApPeerScreen peerId="demo-peer-01"
peerOptions={
{
key:'___your_key___'
}
}
peerEnabled={state.streaming}
/>
</fieldset>
</div>
)
},
_startStreaming() {
const s = this
s.setState({ streaming: true })
},
_stopStreaming() {
const s = this
s.setState({ streaming: false })
}
})
export default DemoComponents
ApPeerCamera
Props
| Name | Type | Default | Description | |
|---|---|---|---|---|
| peerId | string | null | ||
| peerOptions | object | null | ||
| peerEnabled | bool | false | ||
| width | number | ApPeerVideo.DEFAULT_WIDTH | ||
| height | number | ApPeerVideo.DEFAULT_HEIGHT | ||
| audioEnabled | bool | false | ||
| onStart | func | null | ||
| onStop | func | null | ||
| onConnect | func | null | ||
| onError | func | null | ||
| alt | string |
ApPeerScreen
Props
| Name | Type | Default | Description | |
|---|---|---|---|---|
| peerId | string | null | Id for peer | |
| peerOptions | object | null | Peer js options | |
| peerEnabled | bool | false | Enable peer | |
| width | number | ApPeerVideo.DEFAULT_WIDTH | Component width | |
| height | number | ApPeerVideo.DEFAULT_HEIGHT | Component height | |
| onError | func | null | Handler for error events |
ApPeerStyle
Props
| Name | Type | Default | Description | |
|---|---|---|---|---|
| style | object | {} | ||
| highlightColor | string | ApStyle.DEFAULT_HIGHLIGHT_COLOR | ||
| backgroundColor | ApStyle.DEFAULT_BACKGROUND_COLOR |
ApPeerVideo
Props
| Name | Type | Default | Description | |
|---|---|---|---|---|
| width | number | 300 | ||
| height | number | 150 | ||
| alt | string | null | ||
| altIcon | string | 'ion ion-videocamera' | ||
| spinner | string | ApSpinner.DEFAULT_THEME | ||
| spinning | bool | false |
License
This software is released under the MIT License.