Bootstrap

网页中自动播放音乐

在网页中设置自动播放音频

<script type="text/javascript">
    let sound1 = "{{MEDIA_URL}}/media/music/今天你要嫁给我_陶喆,蔡依林.mp3";
    let sound2 = "{{MEDIA_URL}}/media/music/咱们结婚吧_齐晨.mp3";
    let sound3 = "{{MEDIA_URL}}/media/music/甜甜的_周杰伦.mp3";
    let sound4 = "{{MEDIA_URL}}/media/music/苏打绿_小情歌.mp3";
    let x = Math.round(Math.random() * 10);
    if (x < 3) {
        x = sound1;
    } else if (x < 5) {
        x = sound2;
    } else if (x < 8) {
        x = sound3;
    } else if (x <= 10) {
        x = sound4;
    }
    if (navigator.appName == "Microsoft Internet Explorer") {
        document.write('<bgsound src=' + '"' + x + '"' + ' loop="infinite">');
    } else {
        {#document.write('<embed src=' + '"' + x + '"' + 'hidden="true" autostart="true" loop="true">');#}
        document.getElementById("bgm").innerHTML = ('<audio controls="controls" autoplay="autoplay">' +
            '  <source src=' + '"' + x + '" type="audio/mpeg">' +
            'Your browser does not support the audio element.' +'</audio>');
    }
</script>

 

悦读

道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。 故常无欲,以观其妙,常有欲,以观其徼。 此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。

;