进击的码农

微信内自动播放音乐

<body>
    <audio loop="loop" src="./music.mp3" id="media" preload="preload"></audio>
</body>
<script>
    document.addEventListener(
        'WeixinJSBridgeReady',
        function () {
            changeClass()
        },
        false
    )

    function changeClass() {
        var media = document.getElementById('media')
        if (media.paused) {
            media.play()
        } else {
            media.pause()
        }
    }
</script>

回复

This is just a placeholder img.