1.0.18 • Published 5 years ago

the-cam v1.0.18

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

the-cam

Build Status npm Version JS Standard

Embed camera component

Installation

$ npm install the-cam --save

Usage

'use strict'

import 'the-polyfill/apply' // Some browser needs polyfill for ImageCapture API
import React from 'react'
import { TheCam, TheCamStyle, TheCamInput } from 'the-cam'
import { TheSpinStyle } from 'the-spin'

class ExampleComponent extends React.Component {
  state = {
    disabled: false,
    photo01: null,
  }
  start = () => {
    this.setState({ disabled: false })
  }
  stop = () => {
    this.setState({ disabled: true })
  }

  handleUpdate = (v) => this.setState(v)

  render () {
    return (
      <div>
        <TheCamStyle/>
        <TheSpinStyle/>
        <TheCam onStrat={() => console.log('camera started')}
                onStop={() => console.log('camera stopped')}
                disabled={this.state.disabled}
        >
        </TheCam>

        <br/>
        <button onClick={this.start}>Start</button>
        <button onClick={this.stop}>Stop</button>

        <br/>
        <hr/>
        <br/>
        <br/>
        <br/>
        <br/>
        <br/>
        <section>
          <h1>As Input</h1>
          <TheCamInput value={this.state.photo01}
                       name={'photo01'}
                       onUpdate={this.handleUpdate}
          >
          </TheCamInput>
        </section>
      </div>

    )
  }
}

export default ExampleComponent

Components

TheCam

Embed camera component

Props

NameTypeDescriptionDefault
audiounionAudio media constraintfalse
disabledboolCamera disabledfalse
heightunion150
onStreamfuncHandle for streamnull
rejectedMessagenodeMessage to show when camera access rejected'Failed to access camera'
videounionVideo media constrainttrue
widthunion'100%'
onRejectnull
spinningfalse

TheCamInput

Embed camera component

Props

NameTypeDescriptionDefault
audiocustomTheCam.defaultProps.audio
convertFilefunc(file) => readFileAsDataURL(file)
heightcustomTheCam.defaultProps.height
onRejectfuncnull
onUpdatefuncnull
videocustomTheCam.defaultProps.video
widthcustomTheCam.defaultProps.width
valuenull

TheCamStyle

Style for TheCam

Props

NameTypeDescriptionDefault
optionsobjectStyle options{}

License

This software is released under the MIT License.

Links

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago