7***@qq.com
7***@qq.com
  • 发布:2021-08-13 17:33
  • 更新:2021-08-16 10:39
  • 阅读:611

ios小程序真机音频有播放,但是没有声音

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.1.22

第三方开发者工具版本号: 1.05.2107221

基础库版本号: 2.17.3

项目创建方式: HBuilderX

操作步骤:
 playAudio() {  
      if (this.innerAudioContext) {  
        // 获取当前播放状态  
        let paused = this.innerAudioContext.paused;  
        console.log("paused", paused);  
        if (paused) {  
          this.innerAudioContext.play();  
        } else {  
          this.innerAudioContext.pause();  
        }  
      } else {  
        uni.showToast({  
          icon: "none",  
          title: "音频加载中...",  
        });  
        this.innerAudioContext = uni.createInnerAudioContext();  
        console.log(" this.innerAudioContext", this.innerAudioContext);  
        this.innerAudioContext.autoplay = true;  
        this.innerAudioContext.obeyMuteSwitch = false;  
        // this.innerAudioContext.src = this.audioUrl;  
        this.innerAudioContext.src =  
          "http://img.artstudent.cn/pr/2021-03-03/049237b0092943d3b9c4d9ce04f86bc1.mp3";  
        console.log(this.audioUrl);  
        console.log(" this.innerAudioContext", this.innerAudioContext);  
        this.innerAudioContext.onPlay(() => {  
          console.log("onplay");  
          this.playStatus = true;  
        });  
        this.innerAudioContext.onPause(() => {  
          this.playStatus = false;  
        });  
        this.innerAudioContext.onEnded(() => {  
          this.playStatus = false;  
        });  

        this.innerAudioContext.onStop(() => {  
          this.playStatus = false;  
        });  
        this.innerAudioContext.onError((res) => {  
          this.playStatus = false;  
          uni.showToast({  
            icon: "none",  
            title: res.errMsg,  
          });  
          console.log(res);  
        });  
      }  
    },  

预期结果:

在IOS小程序中可以播放

实际结果:

播放事件有触发,无报错,但是没有声音

bug描述:

音频在微信开发工具里面可以播放、在安卓小程序可以播放、在ios微信小程序中无法播放(播放事件有触发,但是没有声音)

2021-08-13 17:33 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

单独使用微信小程序测试(不使用 uni-app)看下,如果仍然存在,反馈到微信小程序社区

7***@qq.com

7***@qq.com (作者)

静音播放的问题导致

  created() {  
    // 微信ios静音播放无声音问题  
    // #ifdef MP-WEIXIN  
    if (wx.setInnerAudioOption) {  
      wx.setInnerAudioOption({  
        obeyMuteSwitch: false,  
      });  
    }  
    // #endif  
  },

已经没有问题了,谢谢

该问题目前已经被锁定, 无法添加新回复