New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ac-recorder

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ac-recorder

Based on MediaRecorder and AudioContext implementation, it can record audio and canvas on the web page and generate a video file to download locally.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

ac-recorder

基于 MediaRecorder 和 AudioContext 实现,能够录制网页上的 audio 和 canvas,生成一个视频文件下载到本地。 Based on MediaRecorder and AudioContext implementation, it can record audio and canvas on the web page and generate a video file to download locally.

🔗 支持 Chrome 🔗 支持 Safari(实测效果更好)

实例化

实例化参数: constructor(targetAudio, targetCanvas)

  • targetAudio: 可播放音频的 audio 元素或是一个 '#id_name' or '.class_name' css 选择器
  • targetCanvas: 播放动画或视频的 canvas 元素或是一个 '#id_name' or '.class_name' css 选择器

配置参数(可选)

.setOptions()

创建录制器

.createRecorder()

录制器控制方法(主要方法)

.start()
.pause()
.resume()
.stop()

其它方法

.preview()
.closePreview()
.download()
.changeAudio()

Usage

  1. 导入 ACRecorder 类:
import { ACRecorder } from "./index.js";
  1. 实例化 ACRecorder,传入要录制的 audio 元素和 canvas 元素:
let ACR = new ACRecorder(document.querySelector("#audio"), "#canvas");
  1. 设置监听事件(可选):
ACR.setListeners({
  start: () => {...},
  fail: () => {...},
  pause: () => {...},
  resume: () => {...},
  stop: () => {...}
});
  1. 开始录制:
ACR.start();
  1. 暂停录制:
ACR.pause();
  1. 恢复录制:
ACR.resume();
  1. 停止录制:
ACR.stop();
  1. 预览录制视频(可选):
ACR.preview();
  1. 关闭视频预览(可选):
ACR.closePreview();
  1. 下载录制视频(可选):
ACR.download();
  1. 销毁录制器(可选):
ACR.destroy();

Tips

new AudioContext()必须在某个用户操作之后执行,否则会出现“The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page”警告,导致音频无法播放。

Keywords

FAQs

Package last updated on 27 Apr 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc