<audio controls="controls">
<source src="some-audio-file.mp3" type="audio/mpeg;codecs=mp3" />
<!-- if you have an Opus version, also include this:
<source src="some-audio-file.opus" type="audio/ogg;codecs=opus" />
-->
<!-- flash object goes here -->
</audio>
2 回答
Edit:
如果您不想使用JavaScript(是的,这将适用于支持
<audio>
但不支持MP3的浏览器),请尝试以下操作:如果要自动播放,请在音频元素上包含
autoplay
属性 .只需将显示flash声音播放器的代码放入标签中即可 .
编辑:使用canPlayType函数:http://www.whatwg.org/specs/web-apps/current-work/multipage/media-elements.html#dom-navigator-canplaytype
您还可以查看错误属性:http://www.whatwg.org/specs/web-apps/current-work/multipage/media-elements.html#dom-media-error