Skip to content

Commit

Permalink
生成的mp3信息存入set中
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyuecn committed Nov 5, 2019
1 parent 8003a1e commit fc3ab60
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ set={

**注意:set内是数字的明确传数字**,不要传字符串之类的导致不可预测的异常,其他有配置的地方也是一样(感谢`[email protected]`19-01-10发的反馈邮件)。

*注:如果录音结束后生成的音频文件的比特率和采样率和set中的不同,将会把set中的bitRate、sampleRate更新成音频文件的。*

### 【方法】rec.open(success,fail)
请求打开录音资源,如果浏览器不支持录音、用户拒绝麦克风权限、或者非安全环境(非https、file等)将会调用`fail`;打开后需要调用`close`来关闭,因为浏览器或设备的系统可能会显示正在录音。

Expand Down
2 changes: 1 addition & 1 deletion dist/engine/mp3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion recorder.mp3.min.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/engine/mp3.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Recorder.prototype.mp3=function(res,True,False){

//去掉开头的标记信息帧
var meta=mp3TrimFix.fn(data,mp3Size,size,set.sampleRate);
mp3TrimFixLogMeta(meta,set);
mp3TrimFixSetMeta(meta,set);

True(new Blob(data,{type:"audio/mp3"}));
};
Expand Down Expand Up @@ -202,7 +202,7 @@ Recorder.prototype.mp3_complete=function(startCtx,True,False,autoStop){
var This=this;
if(startCtx&&startCtx.worker){
startCtx.call=function(data){
mp3TrimFixLogMeta(data.meta,startCtx.set);
mp3TrimFixSetMeta(data.meta,startCtx.set);
True(data.blob);

if(autoStop){
Expand Down Expand Up @@ -349,10 +349,12 @@ rm:Recorder.mp3ReadMeta
return meta;
}
};
var mp3TrimFixLogMeta=function(meta,set){
var mp3TrimFixSetMeta=function(meta,set){
var tag="MP3信息 ";
if(meta.sampleRate&&meta.sampleRate!=set.sampleRate || meta.bitRate&&meta.bitRate!=set.bitRate){
console.warn(tag+"和设置不匹配",set);
console.warn(tag+"和设置的不匹配set:"+set.bitRate+"kbps "+set.sampleRate+"hz,已更新set:"+meta.bitRate+"kbps "+meta.sampleRate+"hz",set);
set.sampleRate=meta.sampleRate;
set.bitRate=meta.bitRate;
};

var trimFix=meta.trimFix;
Expand Down

0 comments on commit fc3ab60

Please sign in to comment.