var innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.obeyMuteSwitch = false;
innerAudioContext.src = 'url播放地址';
innerAudioContext.play()
- 发布:2023-10-17 17:14
- 更新:2023-11-06 14:46
- 阅读:301
【报Bug】ios真机调试,mp3文件播放报错TypeError: Attempted to assign to readonly property. __ERROR
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 11.2.3 (20D91)
HBuilderX类型: 正式
HBuilderX版本号: 3.8.12
手机系统: iOS
手机系统版本号: iOS 15
手机厂商: 苹果
手机机型: 13 pro
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
var innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.obeyMuteSwitch = false;
innerAudioContext.src = 'url播放地址';
innerAudioContext.play()
var innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.obeyMuteSwitch = false;
innerAudioContext.src = 'url播放地址';
innerAudioContext.play()
预期结果:
按官网文档可正常使用
按官网文档可正常使用
实际结果:
控制台报错,音频无法播放
17:02:44.108 [Vue warn]: Error in v-on handler: "TypeError: Attempted to assign to readonly property."[ERROR] : [Vue warn]: Error in v-on handler: "TypeError: Attempted to assign to readonly property."(found at pages/index.vue:1) ERROR
17:02:44.109 TypeError: Attempted to assign to readonly property. ERROR
控制台报错,音频无法播放
17:02:44.108 [Vue warn]: Error in v-on handler: "TypeError: Attempted to assign to readonly property."[ERROR] : [Vue warn]: Error in v-on handler: "TypeError: Attempted to assign to readonly property."(found at pages/index.vue:1) ERROR
17:02:44.109 TypeError: Attempted to assign to readonly property. ERROR
bug描述:
mp3文件播放报错
设置 innerAudioContext.obeyMuteSwitch = false; 后控制台报错如下:
TypeError: Attempted to assign to readonly property. __ERROR
不设置,可以播放
1 个回复
m***@163.com
obeyMuteSwitch 只能在小程序端使用,APP没法用的。