手机端audio部分手机无法自动播放处理

时间:2022-01-23 18:37:28

<section class="music rotate">
    <audio loop src="/static/wishChina/music1.mp3" id="audio_play" autoplay preload></audio>
</section>

//下面为jquery处理,加载完成,则调用该方法,播放音乐
function audioAutoPlay(id) {
        var audio = document.getElementById(id);
        audio.play();
        document.addEventListener("WeixinJSBridgeReady", function () {
            audio.play();
        }, false);
        document.addEventListener(YixinJSBridgeReady, function () {
            audio.play();
        }, false);
    }