大部分手机都能正常录制10分钟,但是苹果5 版本10.3.3(14G60) 微信版本6.5.21 录制61S后执行了OnStop
//获取语音管理器
export const getRecorderManage = function (that) {
if (that.recorderManager) {
return that.recorderManager;
}
//获取用户是否已经授权 使用语音
if (wx.getRecorderManager) {
const nowThis = this;
const recorderManager = wx.getRecorderManager();
recorderManager.onStart(() => {
console.log(‘recorder start’)
})
recorderManager.onResume(() => {
console.log(‘recorder resume’)
})
recorderManager.onPause(() => {
console.log(‘recorder pause’);
})
recorderManager.onStop((res) => {
console.log(‘recorder stop’, res);
nowThis.recorderManagerEndEvent(res, that);
})
that.recorderManager = recorderManager;
return recorderManager;
} else {
wx.showModal({
title: ‘提示’,
content: ‘当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。’,
success: function (res) {
}
})
}
};
//开始语音录制
export const startVoiceOpt = function (that) {
const nowThis = this;
const recorderManager = nowThis.getRecorderManage(that);
if (recorderManager == null) {
return;
}
const options = {
duration: 600000, //10分钟
sampleRate: 8000,
numberOfChannels: 1,
encodeBitRate: 48000,
format: ‘mp3’,
// frameSize: 50 //如果需要分片上传 才需要传这个
}
recorderManager.start(options)
};