html5的audio標簽只在火狐下支持wav格式的音頻播放,無法兼容IE和google ,
使用audioplayer.js 基本上能支持大部分瀏覽器播放wav音頻文件,經測試IE、火狐、google瀏覽器都可以播放編碼格式為:
的wav格式的音頻
當audio標簽不支持或者audio不能播放相應格式的文件時,播放器將使用迷你模式,使用embed元素來播放音頻,支持的功能將較少,並且各瀏覽器支持功能不一致
使用方法:
1、html中加入audio標簽
<audio controls="controls" id="wavAudio"> <source src="https://osvaldas.info/examples/audio-player-responsive-and-touch-friendly/audio.wav" type="audio/wav" /> </audio>
2、引用jquery和audioplayer.js
<script src="~/Content/assets/js/jquery-1.11.1.min.js"></script> <script src="~/Content/audioplayer.js"></script>
3、播放器代碼
常用自定義選項
classPrefix 插件插入html的class前綴
strPlay 播放按鈕顯示的文字
strPause 暫停按鈕顯示的文字
strVolume 音量按鈕顯示的文字
$(function () {
$('audio').audioPlayer({
classPrefix: 'audioplayer',
strPlay: '播放',
strPause: '暫停',
strVolume: '音量'
});
});
audioplayer網站:https://osvaldas.info/audio-player-responsive-and-touch-friendly
最終效果