微信audio自动播放(ios播放问题)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> </head> <body> <audio id="music" src="music/music.mp3" autoplay="autoplay" loop></audio> <script> audioAutoPlay1('music'); function audioAutoPlay1(id){ var audio = document.getElementById(id); audio.play(); document.addEventListener("WeixinJSBridgeReady", function () { audio.play(); }, false); } </script> </body> </html>
ios多个音效,延迟播放
audioAutoPlay2('music2'); function audioAutoPlay2(id){ var audio = document.getElementById(id); audio.play(); setTimeout(function(){ audio.pause(); },100); document.addEventListener("WeixinJSBridgeReady", function () { audio.play(); setTimeout(function(){ audio.pause(); },100); }, false); document.addEventListener('YixinJSBridgeReady', function() { audio.play(); setTimeout(function(){ audio.pause(); },100); }, false); }