音频如何缓存到本地
发布于 5 年前 作者 isu 849 次浏览 来自 问答
  • 需求的场景描述(希望解决的问题)

打卡成功后播放打卡成功的语音提示,使用以下代码可以实现,但是为避免请求过于频繁,欲把音频缓存在本地,从本地获取

const innerAudioContext = wx.createInnerAudioContext()

innerAudioContext.autoplay = true

innerAudioContext.src = http://139.129.118.14/XiaoYuAn/sound/daka.mp3

innerAudioContext.onPlay(() => {

console.log(‘开始播放’)

})

innerAudioContext.onError((res) => {

console.log(res.errMsg)

console.log(res.errCode)

})

  • 希望提供的能力

希望提供将音频缓存到本地的方法或者播放本地音频的方法

回到顶部