使用uni.createInnerAudioContext在ios手机无法自动播放,可通过jweixin-module来解决
// 安装
npm install jweixin-module --save
const jweixin = require('jweixin-module');
const innerAudioContext = uni.createInnerAudioContext();
jweixin.config({});
jweixin.ready(function(){
WeixinJSBridge.invoke('getNetworkType', {}, function(e){
innerAudioContext.play();
})
})

在iOS设备上使用uni.createInnerAudioContext时遇到自动播放限制,通过引入并配置jweixin-module,结合WeixinJSBridge的getNetworkType方法,可以成功触发音频播放。该方法适用于需要在iOS环境中实现音频自动播放的uni-app应用。

被折叠的 条评论
为什么被折叠?



