我花了一天时间开发通话录音小程序(适用于苹果手机)
最编程
2024-03-27 16:45:27
...
//监听开始录音
recorderManager.onStart(() => {
const time = this.formatDate(new Date())
console.log('录音开始', time)
});
//监听录音暂停
recorderManager.onPause(() => {
const time = this.formatDate(new Date())
console.log('录音暂停', time)
console.log('录音暂停后继续自动录音', time)
recorderManager.resume()
})
//监听录音继续事件
recorderManager.onResume(() => {
const time = this.formatDate(new Date())
console.log('录音继续', time)
})
//监听录音因为受到系统占用而被中断
recorderManager.onInterruptionBegin(() => {
const time = this.formatDate(new Date())
console.log('录音因为受到系统占用而被中断', time)
})
//监听录音结束
recorderManager.onStop((res) => {
const time = this.formatDate(new Date())
console.log('录音结束', time, res)
//录音结束后回调事件返回录音文件临时路径
//innerAudioContext 音频播放器
innerAudioContext.src = res.tempFilePath
});
//监听录音错误事件
recorderManager.onError((err) => {
const time = this.formatDate(new Date())
console.log('录音异常', time, err)
})
上一篇: 如何将实时音视频通话与微信小程序整合?