使用uniapp的方法下载转换
this.myAudio = uni.createInnerAudioContext()
uni.downloadFile({
url: '音频地址',
header: {
"X-Requested-With": "XMLHttpRequest",
Accept: "audio/mp3"
},
success(res) {
that.myAudio.src = res.tempFilePath
this.myAudio.play()
this.myAudio.onEnded(() => {
console.log('要结束了');
this.isPlay = false // 图标由动态变为静态
})
},
fail(e) {
console.log("downloadFile failed", e);
uni.showToast({
title: "下载失败",
duration: 1000
});
}
});