npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-multimedia-capture

v1.2.4

Published

react-multimedia-capture is Multimedia capturing module via React, using HTML5 MediaDevice and MediaRecorder API

Downloads

348

Readme

react-multimedia-capture

Now supports React@16!

react-multimedia capture is module for capturing multimedia from WebBrowser via React. It uses navigator.mediaDevices.getUserMedia and MediaRecorder API, so make sure that your browser supports.

Features

  • Uses supporting getUserMedia API from mediaDevices.getUserMedia/getUserMedia/-vendor_prefix-GetUserMedia.
  • Easy, intuitive interface
  • Video Recording
  • Audio Recording
  • Supports Pausing & Resuming

Example

VideoRecorder Example

Example can found from here: react-multimedia-capture-example. Example demonstrates all features in react-multimedia-capture.


import MediaCapturer from 'react-multimedia-capture';

class VideoExample extends Component {
	...
	render() {
		return (
			<div>
				...
				<h1>Video Recording Example</h1>
				<hr />

				<MediaCapturer
					constraints={{ audio: true, video: true }}
					timeSlice={10}
					onGranted={this.handleGranted}
					onDenied={this.handleDenied}
					onStart={this.handleStart}
					onStop={this.handleStop}
					onPause={this.handlePause}
					onResume={this.handleResume}
					onError={this.handleError}
					onStreamClosed={this.handleStreamClose}
					render={({ request, start, stop, pause, resume }) => 
					<div>
						<p>Granted: {granted.toString()}</p>
						<p>Rejected Reason: {rejectedReason}</p>
						<p>Recording: {recording.toString()}</p>
						<p>Paused: {paused.toString()}</p>

						{!granted && <button onClick={request}>Get Permission</button>}
						<button onClick={start}>Start</button>
						<button onClick={stop}>Stop</button>
						<button onClick={pause}>Pause</button>
						<button onClick={resume}>Resume</button>
						
						<p>Streaming test</p>
						<video autoPlay></video>
					</div>
				} />
			</div>
		);
	}
}

Props

Object constraints

Set the getUserMedia constraints. Default is { video: true, audio: true }.

String className

Set the class name of the element.

String mimeType

Set mimeType for MediaRecorder API. It uses 'video/webm;codecs=vp8' by default. If you are trying to record Audio, you should use 'audio/webm' instead.

Number timeSlice (default 10)

Set time slice of mediaRecorder.start.

Function onGranted(MediaStream stream)

Handler that fires on browser acquired permission to access media devices. From @1.2.1, MediaStream passing through first argument.

Function onDenied(Error err)

Handler that fires on browser denied permission to access media devices.

Function onStart(MediaStream stream)

Handler that fires on user started recording.

Function onStop(Bool stopStream)

Handler that fires on user stopped recording. This method will stop MediaStream, but if you want to stay alive, set stopStream to false.

Function onPause

Handler that fires on user paused recording.

Function onResume(MediaStream stream)

Handler that fires on user resumed recording.

Function onError(Error err)

Handler that fires on error occurs. This also could be fired if the browser not support getUserMedia and mediaRecorder API.

Function onStreamClosed

Handler that fires when stream is closed. This happens when you stop the record. After stopped record, you can't start record before get permission again to get new MediaStream to work.

Function render({ request, start, stop, pause, resume })

Render the child components with functions. Each function actually manipulate recording related jobs into parent like VideoRecorder or AudioRecorder.

  • request: Function to get permission of recording media.
  • start: Function to start recording.
  • stop: Function to stop recording.
  • pause: Function to pause recording.
  • resume: Function to resume recording.

Updates

1.0.2

  • Added stop recording on unmounting component

1.1.1

  • Fixed event typo in ondataavailable

1.2.0

  • Fixed "Cannot find module" issue using with Webpack

1.2.1

  • Passing MediaStream to onGranted props.

1.2.2

  • Fixed Stop recording doesn't work anymore
  • Added functionality to request permission after stop recording

1.2.3

  • Updated Stop method to decide stop MediaStream or not.

1.2.4

  • Updated to support changing camera.