收藏
回答

createInnerAudioContext()真机播放报错?

let innerAudioContext = null;

onLoad: function (options{
  innerAudioContext = wx.createInnerAudioContext({
    useWebAudioImplement: true
  });
  //以下监听事件只需要注册一次就行
 innerAudioContext.onPlay(() => { //监听播放事件
 })
 innerAudioContext.onStop(() => { //监听停止事件
 })
 innerAudioContext.onPause(() => { //监听暂停事件
 })
 innerAudioContext.onError((res) => {
  console.log(res.errMsg)
  console.log(res.errCode)
 })
},
//播放录音  第一种方式 --------
playRecordfunction (e{
  var idx = parseInt(e.currentTarget.dataset.index);
 var src = that.data.wxchatLists[idx].content;
 console.log(src)
  innerAudioContext.src = res.tempFilePath;
 innerAudioContext.play();
},
//播放录音  第二种方式 --------
playRecord2function (e{
  var idx = parseInt(e.currentTarget.dataset.index);
 var src = that.data.wxchatLists[idx].content;
 console.log(src)
  wx.downloadFile({
    url: src,
    success(res) => {
      if (res.statusCode === 200) {
        console.log('下载成功');
        innerAudioContext.src = res.tempFilePath;
        innerAudioContext.play();
      }
    }
  })
},


在模拟器上很流畅,可以正常播放, 在手机上真机测试的时候点击无反应,出现

{"errCode": 26, "errMsg": "data error"}

或者

set audio src "https://img.3craftsman.cn/storage/audios/20230717/*******.mp3" fail: data error

这个报错不清楚是哪一步报错的,request合法域名也有添加,https证书也没有问题,src路径固定写死或者本地路径都试了, 都是出现 "errCode": 26。

调试基础库:2.33.0

测试手机:华为P40


麻烦帮我看一下哈~ 比较着急 SOS!

回答关注问题邀请回答
收藏

2 个回答

  • sine
    sine
    2023-07-19

    其他手机会有这个问题吗

    2023-07-19
    有用
    回复 4
    • abyss ;
      abyss ;
      2023-07-19
      图一:iPhone13
      图二:华为P40 (鸿蒙)
      2023-07-19
      回复
    • sine
      sine
      2023-07-19回复abyss ;
      可能和音频压缩格式有关。你先换个压缩格式试试,我们会同步查这个问题
      2023-07-19
      回复
    • abyss ;
      abyss ;
      2023-07-19回复sine
      ok, 试了一下确实是这个原因。 感谢!
      2023-07-19
      回复
    • sine
      sine
      2023-07-26回复abyss ;
      音频虽然看着是mp3,其实是webm格式,目前手机端不支持。要用正常的mp3格式
      2023-07-26
      回复
  • 社区技术运营专员-Jahozheng
    社区技术运营专员-Jahozheng
    2023-07-18

    请具体描述问题出现的流程,并按照链接提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2023-07-18
    有用
    回复 5
登录 后发表内容