如何实现html5音频标签的闪回后备?例如,我有这个音频标签
<div class = "div.jp-audio"><audio class ="audio-player" name= "audio-player" src="song.mp3" ></audio></div>
解决方法
这是一个很好的代码片段,它有一个很好实现的Flash回调:
<audio id="audioplayer" preload controls loop style="width:424px;"> <source src="audio.mp3"> <source src="audio.caf"> </audio> <script type="text/javascript"> var audioTag = document.createElement('audio'); if (!(!!(audioTag.canPlayType) && ("no" != audioTag.canPlayType("audio/mpeg")) && ("" != audioTag.canPlayType("audio/mpeg")))) { AudioPlayer.embed("audioplayer",{soundFile: "audio.mp3"}); } </script>
这是我发现它的参考:
Getting HTML5 Audio Tag and Flash Fallback to Work Nicely With All Browsers
希望能帮助到你!