s

前端疑难杂症

苹果手机自动播放或者控制播放

苹果手机audio标签单单控制play()没声音,需要通过再次加载音效

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if ($('#auidoSuccess').length) {
$('#auidoSuccess').attr('src', 'themes/audio/weixinyaoyy.mp3')
function audioAutoPlay(id) {
var audio = document.getElementById(id);
audio.load();
document.addEventListener("WeixinJSBridgeReady", function () {
WeixinJSBridge.invoke('getNetworkType', {}, function (e) {
audio.load();
});
}, false);
document.addEventListener('YixinJSBridgeReady', function () {
audio.load();
}, false);
}
audioAutoPlay('auidoSuccess')
}
}
playMusic()