uni-app 页面多次触发录音事件导致app闪退
uni-app 页面多次触发录音事件导致app闪退
项目信息 | 详情 |
---|---|
产品分类 | uniapp/App |
PC开发环境操作系统 | Windows |
PC开发环境操作系统版本号 | win10 |
HBuilderX类型 | 正式 |
HBuilderX版本号 | 4.08 |
手机系统 | Android |
手机系统版本号 | Android 11 |
手机厂商 | 小米 |
手机机型 | 小米10青春版 |
页面类型 | vue |
vue版本 | vue2 |
打包方式 | 云端 |
项目创建方式 | HBuilderX |
示例代码:
/**
* 初始化-录音监听事件
*/
initRecorderListeners() {
// 监听录音开始
recorderManager.onStart(() => {
let auRef
if (this.isGroup) {
auRef = this.$refs['actionRef' + this.currentUser.id][0]
} else {
auRef = this.$refs['actionRef']
}
auRef.audio.startTime = Date.now()
auRef.audio.recording = true
})
//监听录音结束-发送
recorderManager.onStop((res) => {
let auRef, id
let endTime = Date.now()
id = this.currentUser.id
if (this.isGroup) {
auRef = this.$refs['actionRef' + this.currentUser.id][0]
} else {
auRef = this.$refs['actionRef']
}
let duration = endTime - auRef.audio.startTime
if (duration < 1000) {
uni.showToast({
icon: 'error',
title: '录音时间太短',
duration: 500
})
setTimeout(() => {
auRef.audio.recording = false
}, 500)
return
}
res.duration = duration
this.sendAudioMessage(res.tempFilePath, id)
setTimeout(() => {
auRef.audio.recording = false
}, 500)
})
}
操作步骤:
- 多次点击录音
预期结果:
- 不闪退
实际结果:
- 闪退
bug描述:
页面写了录音的监听,多次触发录音事件,直接闪退,控制台不输出任何错误日志
更多关于uni-app 页面多次触发录音事件导致app闪退的实战教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复