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

glrecorder

v1.1.2

Published

H5录音器 支持mp3 wave格式的录音

Downloads

49

Readme

GLRecorder

H5录音器 支持mp3 wave格式的录音

浏览器环境下使用(必须在localhost/127.0.0.1或https环境下使用)

npm

npm i glrecorder

import GLRecorder from 'glrecorder';

script

<script type="text/javascript" src="GLRecorder.min.js"></script>

使用

初始化

let recorder = new GLRecorder({
    // 声道数 (1, 2) 默认 2
    numChannels: 2,
    // 采样率 (8000, 11025, 16000, 22050, 44100, 48000) 默认 麦克风默认采样率
    sampleRate: 16000,
    // 比特率 (8, 16, 32) 默认 16 (目前仅支持16)
    bitRate: 16,
});

属性

data 录音数据

recorder.data 

{ 
    blob: 录音数据Blob, 
    type: 录音格式("audio/mp3, audio/wav"), 
    size: 录音大小(B), 
    duration: 录音时长(ms) 
}

recording 是否正在录音

recorder.recording

true / false

ready 是否已经初始化

recorder.ready

true / false

方法

init() 初始化录音器(唤起用户授权弹窗)

recorder.init()
    .then(code => console.log(code))
    .catch(err => console.log(err));

start(mime) 开始录音

mime 录制格式:

'mp3' 录制MP3格式
'wave' 录制WAVE格式(默认)
recorder.start('mp3')
    .then(data => console.log('开始录制MP3'))
    .catch(err => console.log(err));

recorder.start()
    .then(data => console.log('开始录制WAVE'))
    .catch(err => console.log(err));

stop() 停止录音

recorder.stop()
    .then(data => console.log('录音数据:', data)
    .catch(err => console.log(err));

clear() 清空录音数据

recorder.clear()
    .then(data => console.log('清空录音数据'));
    .catch(err => console.log(err));

upload( url, extra ) 上传录音数据

url 上传录音地址
extra 上传录音额外参数
recorder.upload('/upload', { a: 1, b: 2, c: 3 })
    .then(res => res.json().then(data => console.log('上传成功:', data)))
    .catch(err => console.log('上传失败:', err))

save( name ) 保存录音数据

name 保存的录音名称 (默认 'audio')
recorder.save()
    .then(data => console.log('保存成功:', data))
    .catch(err => console.log('保存失败:', err))

静态方法

support() 浏览器是否支持录音功能

GLRecorder.support();

true / false