音频播放,先下载到本地再播放
This commit is contained in:
@@ -32,20 +32,27 @@
|
|||||||
// 播放语音消息
|
// 播放语音消息
|
||||||
onPlayMsg() {
|
onPlayMsg() {
|
||||||
console.log('播放', this.msg.remote);
|
console.log('播放', this.msg.remote);
|
||||||
let innerAudioContext = uni.createInnerAudioContext()
|
uni.downloadFile({
|
||||||
innerAudioContext.src = this.msg.remote
|
url: this.msg.remote,
|
||||||
if (this.audioContextPaused) {
|
success: (res) => {
|
||||||
innerAudioContext.play()
|
if (res.statusCode === 200) {
|
||||||
this.audioContextPaused = false
|
let innerAudioContext = uni.createInnerAudioContext()
|
||||||
return
|
innerAudioContext.src = res.tempFilePath
|
||||||
}
|
if (this.audioContextPaused) {
|
||||||
innerAudioContext.stop()
|
innerAudioContext.play()
|
||||||
innerAudioContext.onStop(resStop => {
|
this.audioContextPaused = false
|
||||||
console.log('停止');
|
return
|
||||||
this.audioContextPaused = true
|
}
|
||||||
})
|
innerAudioContext.stop()
|
||||||
innerAudioContext.onError(err => {
|
innerAudioContext.onStop(resStop => {
|
||||||
console.log(err);
|
console.log('停止');
|
||||||
|
this.audioContextPaused = true
|
||||||
|
})
|
||||||
|
innerAudioContext.onError(err => {
|
||||||
|
console.log(err);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user