Best way to embed audio in a webpage?

前端 未结 1 498
失恋的感觉
失恋的感觉 2021-01-18 21:52

I know, I know. It sounds horrific, but it\'s what the client wants, and they\'re very set on the idea. It\'s now come to me to figure out the best way make it happen. Flash

相关标签:
1条回答
  • 2021-01-18 22:23

    Here's the solution I ended up with. It works with IE7, IE8, IE9, FF3.5, FF4, Safari and Chrome.

    <audio id="background_audio" autoplay="autoplay">
      <source src="static/audio/clip.ogg" type="audio/ogg" />
      <source src="static/audio/clip.mp3" type="audio/mpeg" />
    </audio> 
    
    <!--[if (!IE)|(gte IE 9)]>
    <a href="#" onclick="document.getElementById('background_audio').muted = true; return false">mute sound</a>
    <![endif]-->
    
    <!--[if lt IE 9]>
    <bgsound id="background_snd" src="static/audio/clip.mp3" autostart="true" loop="1">
    <a href="#" onclick="document.all['background_snd'].src=''; return false">mute sound</a>
    <![endif]--> 
    
    0 讨论(0)
提交回复
热议问题