From 50cb518620789931ddab3cd88a094d1fd6c44f7d Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 30 Jan 2022 18:20:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E9=A2=91=E6=92=AD=E6=94=BE=EF=BC=8C?= =?UTF-8?q?=E5=85=88=E4=B8=8B=E8=BD=BD=E5=88=B0=E6=9C=AC=E5=9C=B0=E5=86=8D?= =?UTF-8?q?=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/im/imAUDIO.vue | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/components/im/imAUDIO.vue b/components/im/imAUDIO.vue index 8fad659..f6cacc1 100644 --- a/components/im/imAUDIO.vue +++ b/components/im/imAUDIO.vue @@ -32,20 +32,27 @@ // 播放语音消息 onPlayMsg() { console.log('播放', this.msg.remote); - let innerAudioContext = uni.createInnerAudioContext() - innerAudioContext.src = this.msg.remote - if (this.audioContextPaused) { - innerAudioContext.play() - this.audioContextPaused = false - return - } - innerAudioContext.stop() - innerAudioContext.onStop(resStop => { - console.log('停止'); - this.audioContextPaused = true - }) - innerAudioContext.onError(err => { - console.log(err); + uni.downloadFile({ + url: this.msg.remote, + success: (res) => { + if (res.statusCode === 200) { + let innerAudioContext = uni.createInnerAudioContext() + innerAudioContext.src = res.tempFilePath + if (this.audioContextPaused) { + innerAudioContext.play() + this.audioContextPaused = false + return + } + innerAudioContext.stop() + innerAudioContext.onStop(resStop => { + console.log('停止'); + this.audioContextPaused = true + }) + innerAudioContext.onError(err => { + console.log(err); + }) + } + } }) } }