@bigbinary/neeto-media-recorder

中文文档
2.7.60发布于 2026/11/02MITES Module零依赖近 30 天下载 1949

A package to simplify the media capturing process

原始使用文档
文档目录10 节
  1. Overview
  2. Used by
  3. Installation
  4. Usage
  5. Components
  6. Utilities
  7. Constants
  8. Core
  9. Development
  10. Using host application

@bigbinary/neeto-media-recorder

npm npm

Overview

@bigbinary/neeto-media-recorder is a React package that simplifies the media capturing process. It records the device's screen and audio and uploads the recording to AWS S3 storage using multipart uploads. Recordings are capped at 15 minutes, and the package works across plain web apps, Electron, and browser extensions.

It ships four sets of exports:

  • Components — a MediaRecorder React component with built-in UI controls to start, pause/resume, discard, and restart a recording.
  • Core — a singleton screenRecorder class that handles screen and audio capture, a getMultipartS3Uploader method, and a useMultipartS3UploadStatus React hook for tracking upload progress.
  • Utilities — helpers such as generatePublicUrl to build a shareable link for a recording.
  • Constants — recorder status, event, and error enums plus browser/extension detection helpers.

Used by

This package powers the screen recording experience across the neeto-record suite:

Installation

yarn add @bigbinary/neeto-media-recorder

Usage

This package exports four different sets of functions and components.

  1. Components
  2. Utilities
  3. Constants
  4. Core

Components

  • MediaRecorder

    The MediaRecorder react component capture's device screen and upload it to the AWS S3 storage. It contains UI controls to start, pause/resume, discard and restart a recording.

    You can import the components from @bigbinary/neeto-media-recorder.

    import { MediaRecorder } from "@bigbinary/neeto-media-recorder";
    

    MediaRecorder accepts three props:

    • onUploadComplete: This callback will get triggered once the uploading of the screen recording is completed.
    • onRecordingCreated: This callback will get triggered with the recording once it is created on the server, before any of it is uploaded.
    • onDiscard: This callback will get triggered whenever the user discard's the screen recording.
    • appName: This prop is used to set the application name which will be used in the permission denied messages. By default it will be set to globalProps.appName
    • mimeType: This prop is used to set the mime type of the recording. By default it will be set to video/webm;codecs=h264.

Utilities

You can import utilities from @bigbinary/neeto-media-recorder/utils.

import { generatePublicUrl } from "@bigbinary/neeto-media-recorder/utils";
  • generatePublicUrl(recordingId, baseURL = window.location.origin)

    Can be used to generate the public URL for a screen recording by providing the recordingId and baseURL as arguments.

Constants

You can import constants from @bigbinary/neeto-media-recorder/constants.

import { UPLOAD_EVENT, UPLOAD_STATUS,... } from "@bigbinary/neeto-media-recorder/constants"

The available constants are:

const UPLOAD_EVENT = { onComplete: "onComplete" };

const UPLOAD_STATUS = {
  uploading: "uploading",
  completed: "completed",
  aborting: "aborting",
};

const SCREEN_RECORDER_STATUS = {
  media_aborted: "media_aborted",
  permission_denied: "permission_denied",
  no_specified_media_found: "no_specified_media_found",
  media_in_use: "media_in_use",
  invalid_media_constraints: "invalid_media_constraints",
  no_chrome_flags_set: "no_chrome_flags_set",
  recorder_error: "recorder_error",
  idle: "idle",
  acquiring_media: "acquiring_media",
  media_acquired: "media_acquired",
  restarting: "restarting",
  recording: "recording",
  stopping: "stopping",
  stopped: "stopped",
  paused: "paused",
};

const SCREEN_RECORDER_ERROR = {
  AbortError: "media_aborted",
  NotAllowedError: "permission_denied",
  NotFoundError: "no_specified_media_found",
  NotReadableError: "media_in_use",
  OverconstrainedError: "invalid_media_constraints",
  TypeError: "no_chrome_flags_set",
  None: "",
  NoRecorder: "recorder_error",
  UnSupportedBrowser: "unsupported_browser",
};

const SCREEN_RECORDER_EVENT = {
  onStart: "onStart",
  onStop: "onStop",
  onDiscard: "onDiscard",
  onDataAvailable: "onDataAvailable",
  onDiscardDuringCountdown: "onDiscardDuringCountdown",
  onRestart: "onRestart",
  onReUpload: "onReUpload",
  onReUploadFromDisk: "onReUploadFromDisk",
  onPause: "onPause",
  onResume: "onResume",
};

const HAS_CHROME_NAMESPACE = typeof chrome === "object";

const IS_EXTENSION = HAS_CHROME_NAMESPACE && isNotNil(chrome.extension);

const IS_SAFARI = platform.name === "Safari";

const IS_SAFARI_EXTENSION = IS_SAFARI && IS_EXTENSION;

Core

The @bigbinary/neeto-media-recorder/core contains a singleton class screenRecorder and getMultipartS3Uploader method and a react hook useMultipartS3UploadStatus.

import {
  screenRecorder,
  getMultipartS3Uploader,
  useMultipartS3UploadStatus,
} from "@bigbinary/neeto-media-recorder/core";
  • screenRecorder

    It handles the screen and audio capturing process. The recordings are limited to 15 minutes. The various methods provided by screenRecorder are:

    • startRecording()

      Used to start screen recording.

    • stopRecording()

      Used to stop the current screen recording.

    • pauseRecording()

      Used to pause the current screen recording.

    • resumeRecording()

      Used to resume the screen recording.

    • discardRecording()

      Used to discard the current screen recording.

    • restartRecording()

      Used to discard the current screen recording and start a new one.

    • addCallback(event, callback)

      Used to add callback function for a specific screen recording event. The constant SCREEN_RECORDER_EVENT contains all the possible screen recording events.

      screenRecorder.addCallback(
        SCREEN_RECORDER_EVENT.onStart,
        handleStartRecording
      );
      
    • removeCallback(event, callback)

      Used to remove an already added callback by providing the event and callback to be removed.

      screenRecorder.removeCallback(
        SCREEN_RECORDER_EVENT.onStart,
        handleStartRecording
      );
      
    • removeAllCallbacksByEvent(event)

      Used to remove all callbacks associated with a particular event.

      screenRecorder.removeCallback(SCREEN_RECORDER_EVENT.onStart);
      
    • resetState()

      Used to reset the internal states of the screenRecorder to initial state.

    • revokePermissions()

      Used to revoke the browser permission to access the MediaRecorder api.

    • useRecorderStore()

      A zustand store which can be used know the screenRecorder status and error if any occurred inside a react component

    • setAudioConfiguration({ deviceId, ...}) Used to set the configuration for the audio device. Ref: https://w3c.github.io/mediacapture-main/#dom-mediatracksupportedconstraints

    • videoStream A write-only property which can be set by the client to set a video stream, once set the screenRecorder will not acquire a new video stream or request for permission to share the screen.

  • getMultipartS3Uploader

    It returns an instance of MultipartS3Uploader which handles the upload of recorded screen data to AWS S3 storage.

    getMultipartS3Uploader optionally accepts an object with the following properties:

    • initialize

      When set to true, it will automatically initialize a new instance of MultipartS3Uploader and returns it. This is useful when you want to clean up the existing multipart uploader instance and create a new one.

    The MultipartS3Uploader instance returned by getMultipartS3Uploader provides the ability to upload the recording to S3 in multiple chunks. The methods provided by MultipartS3Uploader instance are:

    • setRecording(recordingId, uploadId)

      Used to initialize the multipartS3Uploader by providing the recordingId and uploadId. recordingId and uploadId can be obtained by creating a new recording in neeto-record-web.

    • push(data)

      Used to upload the recorded chunk to S3.

    • completeUpload()

      Once the recording is completed this method should be called to mark the recording as completed.

    • abortUpload()

      Used to discard the partially uploaded recording.

    • resetState()

      Used to reset the internal state of multipartS3Uploader to initial state.

    • addCallback(event, callback)

      Used to add callback function to a specific upload event. The constant UPLOAD_EVENT contains all the possible upload events.

    • removeCallback(event, callback)

      Used to remove an already added callback by providing the event and callback to be removed.

    • status

      A property which returns the current status of the MultipartS3Uploader instance.

    • mimeType

      A property which returns the mime type of the recording.

    • setMimeType(mimeType)

      Used to set the mime type of the recording.

  • useMultipartS3UploadStatus

    A react hook which can be used to know the current status of the MultipartUploader instance. It rerenders the component whenever the status changes.

    const { status, isStatus } = useMultipartS3UploadStatus();
    // `status` can be one of the following:
    // UPLOAD_STATUS.uploading, UPLOAD_STATUS.completed, UPLOAD_STATUS.aborting, UPLOAD_STATUS.error, UPLOAD_STATUS.insufficient_data
    // `isStatus` is a function which can be used to check if the current status is one of the given statuses.
    isStatus(UPLOAD_STATUS.uploading); // will return true if the current status is UPLOAD_STATUS.uploading
    isStatus(UPLOAD_STATUS.uploading, UPLOAD_STATUS.completed); // will return true if the current status is either UPLOAD_STATUS.uploading or UPLOAD_STATUS.completed
    

Development

Install all the dependencies by executing the following command

yarn install

Using host application

  1. Clone this repository.
  2. Run yarn install to download the dependencies and setup the development environment.
  3. Have a host application ready.
  4. Run yarn watch to automatically transpile code as you save the file. You can run yarn build if you want to run the build only once.
  5. In a different terminal, run yalc publish to publish the neeto-media-recorder to the local yalc store.
  6. Run yalc add @bigbinary/neeto-media-recorder to install the neeto-media-recorder to the host application.
  7. After making necessary changes to neeto-media-recorder, run yarn release to push the changes to the host application (assuming that you are in watch mode and the changes are bundled automatically). Restart webpack-dev-server in host if changes are not applied.
  8. Video explanation on how to use yalc: https://www.youtube.com/watch?v=QBiYGP0Rhe0

Building and releasing.

The @bigbinary/neeto-neeto-media-recorder package gets published to NPM when we merge a PR with patch, minor or major label to the main branch. The patch label is used for bug fixes, minor label is used for new features and major label is used for breaking changes. You can checkout the Create and publish releases workflow in GitHub Actions to get a live update.

In case if you missed to add the label, you can manually publish the package. For that first you need to create a PR to update the version number in the package.json file and merge it to the main branch. After merging the PR, you need to create a new github release from main branch. Whenever a new release is created with a new version number, the github actions will automatically publish the built package to npm. You can checkout the Publish to npm workflow in GitHub Actions to get a live update.

Please note that before publishing the package, you need to verify the functionality in some of the neeto web-apps locally using yalc package manager.

Project integrations

Projectsneeto-media-recorder
neeto-record-web:white_check_mark:
neeto-record-chrome-extension:white_check_mark:

版本与发布记录

@bigbinary/neeto-media-recorder 共发布 166 个版本,首次发布于 2023/11/28;过去 12 个月发布了 46 个版本。

版本发布日期距今
2.7.60latest2026/11/026 天前
2.7.592026/10/2118 天前
2.7.582026/10/0930 天前
2.7.572026/10/051 个月前
2.7.562026/09/211 个月前
2.7.552026/09/181 个月前

其他发布通道:beta → 2.6.16-beta.1。

关于 @bigbinary/neeto-media-recorder 的常见问题

@bigbinary/neeto-media-recorder 是什么?

A package to simplify the media capturing process

如何安装 @bigbinary/neeto-media-recorder?

在项目目录运行 npm install @bigbinary/neeto-media-recorder,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:axios(0.27.2)、ramda(^0.29.0)、react(^17.0.2)、zustand(4.3.2)、platform(^1.3.6)、js-logger(^1.6.1)、react-dom(17.0.2)、classnames(^2.3.2)、lucide-react(^1.8.0)、react-i18next(12.3.1)、react-router-dom(5.3.1)、@bigbinary/neetoui(8.2.18)、@bigbinary/neeto-cist(latest)、@tanstack/react-query(5.40.0)、@bigbinary/neeto-atoms(^1.0.90)、@bigbinary/neeto-icons(1.17.6)、@bigbinary/neeto-molecules(5.2.0)、@bigbinary/neeto-media-recorder(latest)、@bigbinary/neeto-commons-frontend(latest)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bigbinary/neeto-media-recorder 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bigbinary__neeto-media-recorder 是否存在。

@bigbinary/neeto-media-recorder 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bigbinary/neeto-media-recorder 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bigbinary/neeto-media-recorder 可以商用吗?

@bigbinary/neeto-media-recorder 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bigbinary/neeto-media-recorder 的下载量有多少?

根据 npm 官方下载统计,@bigbinary/neeto-media-recorder 在 2026/10/08 – 2026/11/06 这 30 天内被下载 1,949 次,日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bigbinary/neeto-media-recorder 还在维护吗?

最新版本 2.7.60 发布于 2026/11/02(6 天前);至今共发布 166 个版本,其中过去 12 个月发布了 46 个;首次发布于 2023/11/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。