微信小程序wx.createInnerAudioContext播放play报错errMsg: “operateAudio:fail jsapi has no permission, event=ope

简介: 微信小程序wx.createInnerAudioContext播放play报错errMsg: “operateAudio:fail jsapi has no permission, event=ope

微信小程序wx.createInnerAudioContext播放play报错解决

微信小程序wx.createInnerAudioContext播放play报错errMsg: “operateAudio:fail jsapi has no permission, event=operateAudio, runningState=background, permissionMsg=permission got, detail=jsapi has no permission”

解决方案:

在创建onError回调函数再次执行播放函数

//播放语音
yuyinPlay(e) {
    if (this.src == '') {
      console.log(暂无语音);
      return;
    }
    this.innerAudioContext.src = this.src
    this.innerAudioContext.play();
},
onReady() {
  // ios端音频不能在静音下播放处理
  wx.setInnerAudioOption({
     obeyMuteSwitch: false,
     success: function (res) {
         console.log("开启静音模式下播放音乐的功能");
     },
     fail: function (err) {
         console.log("静音设置失败");
     },
  });
  //创建内部 audio 上下文 InnerAudioContext 对象。
  this.innerAudioContext = wx.createInnerAudioContext();
  this.innerAudioContext.onError((res) => {
    console.log(res);
    this.yuyinPlay();
    wx.showToast({
    title: '语音播放失败',
    icon: 'none',
    })
  })
},


相关文章
|
小程序 前端开发 JavaScript
uniapp转微信小程序编译报错 Bad attr `data-event-opts` with message
uniapp转微信小程序编译报错 Bad attr `data-event-opts` with message
|
9月前
|
JSON 小程序 JavaScript
uni-app开发微信小程序的报错[渲染层错误]排查及解决
uni-app开发微信小程序的报错[渲染层错误]排查及解决
2011 7
|
9月前
微信接口报错 "errcode":40163,"errmsg":"code been used, 如何处理?
【10月更文挑战第11天】微信接口报错 "errcode":40163,"errmsg":"code been used, 如何处理?
4565 1
|
12月前
|
文字识别 小程序 安全
印刷文字识别操作报错合集之微信小程序调用API时路径总是返回不对,该如何处理
在使用印刷文字识别(OCR)服务时,可能会遇到各种错误。例如:1.Java异常、2.配置文件错误、3.服务未开通、4.HTTP错误码、5.权限问题(403 Forbidden)、6.调用拒绝(Refused)、7.智能纠错问题、8.图片质量或格式问题,以下是一些常见错误及其可能的原因和解决方案的合集。
|
小程序 API
微信小程序getLocation报错 getLocation:fail the api need to be declared in the requiredPrivateInfos field in
微信小程序getLocation报错 getLocation:fail the api need to be declared in the requiredPrivateInfos field in
714 1
|
移动开发 小程序 开发工具
微信支付的类型分析(JSAPI+APP+H5+NATIVE+付款码+合单)
微信支付的类型分析(JSAPI+APP+H5+NATIVE+付款码+合单)
977 1
|
PHP 移动开发 安全
PHP应用如何对接微信公众号JSAPI支付
本文介绍了微信支付的多种方式,包括JSAPI支付、APP支付、Native支付、付款码支付和H5支付。
161 8
|
小程序 开发者
【微信小程序】 微信小程序报错不在以下request合法域名列表中
【微信小程序】 微信小程序报错不在以下request合法域名列表中
1539 0
|
小程序
微信小程序启动报错 WXML file not found: ./miniprogram_npm/@vant/weapp/action-sheet/index.wxml
微信小程序启动报错 WXML file not found: ./miniprogram_npm/@vant/weapp/action-sheet/index.wxml
434 3
|
小程序 前端开发 Android开发
微信小程序(van-tabs) 去除横向滚动条样式(附加源码解决方案+报错图)
微信小程序(van-tabs) 去除横向滚动条样式(附加源码解决方案+报错图)
756 1

热门文章

最新文章