/**
-
初始化-录音监听事件
*/
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)
})
0 个回复