Playing sound on my website

后端 未结 6 1761
鱼传尺愫
鱼传尺愫 2021-01-18 17:40

I use a code to play background music on my website..





        
相关标签:
6条回答
  • 2021-01-18 18:01

    The HTML5 solution is the Audio tag http://www.w3schools.com/tags/tag_audio.asp

    This is the older solution: http://drayblog.gotdns.com/index.php/2009/05/13/html-embed-an-audio-clip-and-repeat-loop-it/

    <EMBED SRC="/audio/media.mp3" AUTOSTART="true" HIDDEN="True" LOOP="True"/>
    <NOEMBED>
        <object type="audio/mp3" data="http://www.domain.com/audio/media.mp3"><param name="src" value="http://www.domain.com/audio/media.mp3"></param><param name="autostart" value="true"></param><param name="hidden" value="True"></param><param name="loop" value="true"></param>
        </object>
    </NOEMBED>
    
    0 讨论(0)
  • 2021-01-18 18:02

    Try using the audio tag instead:

    <audio autoplay loop>
        <source src="sound.ogg">
        <source src="sound.mp3"> 
    </audio>
    

    You need to use both mp3 and ogg files to be able to play your sound correctly in all browsers. Firefox for instance does not support mp3 files. Also using .wav is on websites is severely frowned upon due to its size.

    0 讨论(0)
  • 2021-01-18 18:07
    <audio hidden="true" autoplay loop controls>
        <source src="source.mp3">
    </audio>
    

    it will works fine as you want...

    0 讨论(0)
  • 2021-01-18 18:14

    Instead of loop='true' try with loop='infinite' as below

    <embed src="1.wav" autostart="true" loop="infinite"
    width="2" height="0">
    </embed>
    
    0 讨论(0)
  • 2021-01-18 18:20

    This is what I have found to work the best... Just replace the 'yoursounds' with the actual file name of your chosing.

    <audio autoplay loop controls>
        <source src="yoursound.ogg">
        <source src="yoursound.mp3">
    </audio>
    
    0 讨论(0)
  • 2021-01-18 18:22

    Try jPlayer. It's an html5 media player that will fallback on flash. Here's an example from one of the demos:

    $("#jquery_jplayer_1").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                m4a:"http://www.jplayer.org/audio/m4a/TSP-01-Cro_magnon_man.m4a",
                oga:"http://www.jplayer.org/audio/ogg/TSP-01-Cro_magnon_man.ogg"
            });
        },
        swfPath: "../js",
        solution: "flash, html",
        supplied: "m4a, oga",
        wmode: "window"
    });
    
    <div id="jquery_jplayer_1" class="jp-jplayer"></div>
    

    http://jplayer.org/latest/demo-01-solution-flash-html/

    0 讨论(0)
提交回复
热议问题