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-recorder-3s

v1.4.2

Published

A react component that records audio using the MediaRecorder API

Downloads

2

Readme

react-recorder

A react component that records audio using the MediaRecorder API

This is a slightly tweaked version that prioritizes the usage of the navigator.mediaDevices.getUserMedia() API instead of the deprecated navigator.getUserMedia() (but defaults to it if it the former isn't available).

Installation

npm install react-recorder

Browser Requirements

This component is dependent on browser implementation of both the navigator.getUserMedia and MediaRecorder APIs. Currently only Google Chrome and Mozilla Firefox fully support these APIs. The Recorder component provides an onMissingAPIs prop that allows developers to specify the appropriate behavior if a browser is lacking support for these APIs. If onMissingAPIs is undefined, it defaults to calling the alert function to notify the user to use either Chrome or Firefox.

Example

You can see the Recorder in action here. Check out the source code here.

Usage with Redux

If you're using Redux to handle your client-side state, react-recorder-redux provides actions and reducers for working with this library.

Usage

import React from 'react'
import Recorder from 'react-recorder'

const onStop = (blob) => {
  // Do something with the blob file of the recording
}

const ExampleRecorder = () => (
  <div>
    <Recorder onStop={onStop} />
  </div>
)
export default ExampleRecorder

Props

onStop

The onStop prop is the only required prop for the Recorder component. onStop should be a function with a single argument representing the Blob object returned by the MediaRecorder when recording has stopped. You can then use this Blob object to play back the recorded audio, download the recorded clip, upload the recording to a server, etc.

onMissingAPIs

The onMissingAPIs prop is a function called when the browser fails to implement either the navigator.mediaDevices.getUserMedia, navigator.getUserMedia or MediaRecorder APIs required by the component. The function is passed the values for navigator.getUserMedia and MediaRecorder as arguments in case the developer wants to implement individualized error messages for the various APIs. If onMissingAPIs is left undefined, the default behavior is to call window.alert to notify the user to use either Chrome or Firefox.

onError

The onError prop is a function called when either navigator.getUserMedia or MediaRecorder returns an Error object. The resulting error is passed to the onError function.

onPause

A function called when the MediaRecorder pauses its recording.

onResume

A function called when the MediaRecorder resumes recording after being paused.

onStart

A function called when the MediaRecorder begins recording.

gotStream

A function called after a call to navigator.getUserMedia successfully captures the input audio stream. The function is passed the resulting stream, which can then be used with the Web Audio API to provide audio visualizations, etc.

blobOpts

The options passed to the Blob constructor, including specifying the MIMEType of the resulting Blob object. Defaults to {type: 'audio/wav'}.

mediaOpts

The options passed to the MediaRecorder constructor. Defaults to {}.

constraints

The constraints object passed to the navigator.mediaDevices.getUserMedia function. Defaults to { audio: true }.

command

Useful for Redux-like environments where changes in state are communicated via props. When the command prop is changed, the corresponding method is called. Allowed values are the method name strings (['start', 'stop', 'resume', 'pause']) as well as 'none', representing no method call. Developers can also call these methods directly by accessing the component's ref.

Rendering

The Recorder component does not have an actual representation in the DOM, returning only false in its render method.