forked from xiangyuecn/Recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3b6674
commit ec095a0
Showing
7 changed files
with
27 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# :open_book:Recorder用于html5录音 | ||
|
||
[在线测试](https://xiangyuecn.github.io/Recorder/),支持大部分已实现`getUserMedia`的移动端、PC端浏览器;主要包括:Chrome、Firefox、Safari、Android WebView、腾讯Android X5内核(QQ、微信);不支持:UC系内核(典型的支付宝,大部分国产手机厂商的浏览器)。快捷方式: [【RecordApp测试】](https://jiebian.life/web/h5/github/recordapp.aspx),[【Android、IOS App Demo】](https://github.com/xiangyuecn/Recorder/tree/master/app-support-sample),[【工具】裸(RAW、WAV)PCM转WAV播放测试和转码](https://xiangyuecn.github.io/Recorder/assets/%E5%B7%A5%E5%85%B7-%E8%A3%B8PCM%E8%BD%ACWAV%E6%92%AD%E6%94%BE%E6%B5%8B%E8%AF%95.html) ,[查看caniuse浏览器支持情况](https://caniuse.com/#search=getUserMedia)。 | ||
[在线测试](https://xiangyuecn.github.io/Recorder/),支持大部分已实现`getUserMedia`的移动端、PC端浏览器;主要包括:Chrome、Firefox、Safari、Android WebView、腾讯Android X5内核(QQ、微信);不支持:UC系内核(典型的支付宝,大部分国产手机厂商的浏览器),IOS上除Safari外的其他任何形式的浏览器(含PWA、WebClip)。快捷方式: [【RecordApp测试】](https://jiebian.life/web/h5/github/recordapp.aspx),[【Android、IOS App Demo】](https://github.com/xiangyuecn/Recorder/tree/master/app-support-sample),[【工具】裸(RAW、WAV)PCM转WAV播放测试和转码](https://xiangyuecn.github.io/Recorder/assets/%E5%B7%A5%E5%85%B7-%E8%A3%B8PCM%E8%BD%ACWAV%E6%92%AD%E6%94%BE%E6%B5%8B%E8%AF%95.html) ,[查看caniuse浏览器支持情况](https://caniuse.com/#search=getUserMedia)。 | ||
|
||
录音默认输出mp3格式,另外可选wav格式(raw pcm format此格式录音文件超大);有限支持ogg(beta)、webm(beta)、amr(beta)格式;支持任意格式扩展(前提有相应编码器)。 | ||
|
||
|
@@ -247,7 +247,7 @@ set={ | |
**注意:set内是数字的明确传数字**,不要传字符串之类的导致不可预测的异常,其他有配置的地方也是一样(感谢`[email protected]`19-01-10发的反馈邮件)。 | ||
|
||
### 【方法】rec.open(success,fail) | ||
请求打开录音资源,如果浏览器不支持录音或用户拒绝麦克风权限将会调用`fail`;打开后需要调用`close`来关闭,因为浏览器或设备的系统可能会显示正在录音。 | ||
请求打开录音资源,如果浏览器不支持录音、用户拒绝麦克风权限、或者非安全环境(非https、file等)将会调用`fail`;打开后需要调用`close`来关闭,因为浏览器或设备的系统可能会显示正在录音。 | ||
|
||
注意:此方法回调是可能是同步的(异常、或者已持有资源时)也可能是异步的(浏览器弹出权限请求时);一般使用时打开,用完立即关闭;可重复调用,可用来测试是否能录音。 | ||
|
||
|
@@ -266,15 +266,17 @@ set={ | |
注意:如果创建了多个Recorder对象并且调用了open(应避免同时有多个对象进行了open),只有最后一个新建的才有权限进行实际的资源释放(和多个对象close调用顺序无关),浏览器或设备的系统才会不再显示正在录音的提示。 | ||
|
||
### 【方法】rec.start() | ||
开始录音,需先调用`open`;如果不支持、错误,不会有任何提示,因为stop时自然能得到错误。 | ||
开始录音,需先调用`open`;最佳实践为:每次调用`start`前都调用一次`open`以达到最佳的兼容性,录音`stop`后调用`close`进行关闭;如果不支持、错误,不会有任何提示,因为stop时自然能得到错误。 | ||
|
||
### 【方法】rec.stop(success,fail) | ||
### 【方法】rec.stop(success,fail,autoClose) | ||
结束录音并返回录音数据`blob对象`,拿到blob对象就可以为所欲为了,不限于立即播放、上传 | ||
|
||
`success(blob,duration)`:`blob`:录音数据audio/mp3|wav...格式,`duration`:录音时长,单位毫秒 | ||
|
||
`fail(errMsg)`:录音出错回调 | ||
|
||
`autoClose`:`false` 可选,是否自动调用`close`,默认为`false`不调用 | ||
|
||
提示:stop时会进行音频编码,根据类型的不同音频编码花费的时间也不相同。对于支持边录边转码(Worker)的类型,将极速完成编码并回调;对于不支持的10几秒录音花费2秒左右算是正常,但内部采用了分段编码+setTimeout来处理,界面卡顿不明显。 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.