Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
react-media-recorder
Advanced tools
A React component based on MediaRecorder() API to record audio/video streams
react-media-recorder
is a react component with render prop that can be used to record audio/video streams using MediaRecorder API.
npm i -S react-media-recorder
or
yarn add react-media-recorder
import ReactMediaRecorder from "react-media-recorder";
const RecordView = () => (
<div>
<ReactMediaRecorder
video
render={({ status, startRecording, stopRecording, mediaBlob }) => (
<div>
<p>{status}</p>
<button onClick={startRecording}>Start Recording</button>
<button onClick={stopRecording}>Stop Recording</button>
<video src={mediaBlob} controls />
</div>
)}
/>
</div>
);
Since react-media-recording
uses render prop, you can define what to render in the view. Just don't forget to wire the startRecording
, stopRecording
and mediaBlob
to your component.
render
functionA string enum
. Possible values:
idle
recording
paused
stopped
no_constraints
invalid_media_constraints
no_specified_media_found
media_in_use
media_aborted
permission_denied
delayed_start
(only if a delay
has been set) [deprecating soon]If the audio is muted, you'll see the status suffixed with _muted
.
A function
, which starts recording when invoked.
A function
, which pauses the recording when invoked.
A function
, which resumes the recording when invoked.
A function
, which stops recording when invoked.
A function
, which mutes the audio tracks when invoked.
A function
which unmutes the audio tracks when invoked.
A blob
url that can be wired to an <audio />
, <video />
or an <a />
element.
Can be either a boolean value or a MediaTrackConstraints object.
type: boolean
or object
default: true
From MDN:
An optional BlobPropertyBag
dictionary which may specify the following two attributes (for the mediaBlob
):
type
, that represents the MIME type of the content of the array that will be put in the blob.endings
, with a default value of "transparent", that specifies how strings containing the line ending character \n are to be written out. It is one of the two values: "native", meaning that line ending characters are changed to match host OS filesystem convention, or "transparent", meaning that endings are stored in the blob without changetype: object
default:
if video
is enabled,
{
type: "video/mp4"
}
if there's only audio
is enabled,
{
type: "audio/wav"
}
If you want to start recording after a delay. In milliseconds.
type: number
default: 0
Whether you want to mute the audio (while recording video)
type: boolean
default: false
A function
which accepts an object containing fields: status
, startRecording
, stopRecording
andmediaBlob
. This function would return a react element/component.
type: function
default: () => null
Can be either a boolean value or a MediaTrackConstraints object.
type: boolean
or object
default: false
Will be invoked when the recording stops. This callback will be invoked with the blobUrl as its params.
type: function
default: () => null
Feel free to submit a PR if you found a bug (I might've missed many! :grinning:) or if you want to enhance it further.
Thanks!. Happy Recording!
FAQs
A React component based on MediaRecorder() API to record audio/video streams
The npm package react-media-recorder receives a total of 18,673 weekly downloads. As such, react-media-recorder popularity was classified as popular.
We found that react-media-recorder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.