html⾳频⾳乐播放器插件效果制作
下⾯谈谈html中插⼊⾳频⽂件,经过我的本地测试总结的⼀些问题(播放mp3⽂件):
3、<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="AutoStart" value="1" />
<param name="Src" value="images/hua/start_20160309.mp3" />
<param name="LOOP" value="true">
</object>
问题:在IE7+上能播放,IE8会弹出“⾮正常使⽤的Articx”等字样的提⽰;
Chrome、Opera、Firefox、UC上不能播放;
4、<audio autoplay="autoplay" loop="loop" preload="auto">
<source src="images/hua/start_20160309.mp3" loop="loop" type="audio/mpeg">
<source src="images/hua/" loop="loop" type="audio/mpeg">
<source src="images/hua/start_20160309.wav" loop="loop" type="audio/mpeg">
html播放音乐代码</audio>
问题:html5标签经过测试Chrome、Opera、Firefox、IE9+、UC正常
综合以上本⼈采取了⼀下⽅式(jquery下执⾏):
if(navigator.userAgent.indexOf("Chrome") > -1){
如果是Chrome:
<audio src="" type="audio/mp3" autoplay=”autoplay” hidden="true"></audio>
}else if(navigator.userAgent.indexOf("Firefox")!=-1){
如果是Firefox:
<embed src="" type="audio/mp3" hidden="true" loop="false" mastersound></embed>
}else if(navigator.appName.indexOf("Microsoft Internet Explorer")!=-1 && document.all){
如果是IE(6,7,8):
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param name="AutoStart" value="1" /><param name="Src" value="" /></object>
}else if(navigator.appName.indexOf("Opera")!=-1){
如果是Oprea:
<embed src="" type="audio/mpeg"  loop="false"></embed>
}else{
<embed src="" type="audio/mp3" hidden="true" loop="false" mastersound></embed>
}
var ua = LowerCase();
if(ua.match(/msie ([\d.]+)/)){
jQuery('#__alert_sound').html('<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param
name="AutoStart" value="1" /><param name="Src" value="/sounds/alert/1.mp3" /></object>');
}
else if(ua.match(/firefox\/([\d.]+)/)){
jQuery('#__alert_sound').html('<embed src="/sounds/alert/1.mp3" type="audio/mp3" hidden="true" loop="false" mastersound></embed>');
}
else if(ua.match(/chrome\/([\d.]+)/)){
jQuery('#__alert_sound').html('<audio src="/sounds/alert/1.mp3" type="audio/mp3" autoplay=”autoplay” hidden="true"> </audio>');
}
else if(ua.match(/opera.([\d.]+)/)){
jQuery('#__alert_sound').html('<embed src="/sounds/alert/1.mp3" hidden="true" loop="false"><noembed><bgsounds src="/sounds/alert/1.mp3"></noembed>');
}
else if(ua.match(/version\/([\d.]+).*safari/)){
jQuery('#__alert_sound').html('<audio src="/sounds/alert/1.mp3" type="audio/mp3" autoplay=”autoplay” hidden="true"> </audio>');
}
else {
jQuery('#__alert_sound').html('<embed src="/sounds/alert/1.mp3" type="audio/mp3" hidden="true" loop="false" mastersound></embed>');
}
原⽂来⾃地址为:
本地⽂件效果为:desk/jaket/index.html