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); + }) + } + } }) } }