实现微信浏览器自动播放MP3音乐

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>MP3</title>
        <script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js"></script>
    </head>
    <body>
        <div style="overflow: hidden;">
            <audio src="http://oj1hxt5z0.bkt.clouddn.com/123.mp3" id="Jaudio" class="media-audio" autoplay preload loop="loop"></audio>
        </div>
        <script type="text/javascript">
            function audioAutoPlay(id){
                var audio = document.getElementById(id);
                audio.play();
                document.addEventListener("WeixinJSBridgeReady", function () {
                    audio.play();
                }, false);
                document.addEventListener('YixinJSBridgeReady', function() {
                    audio.play();
                }, false);
            }
        audioAutoPlay('Jaudio');
        </script>
    </body>
</html>

 

posted @ 2017-01-16 10:18  玻璃外的风景  阅读(4373)  评论(0编辑  收藏  举报