足球游戏_中国足彩网¥体育资讯$

在html中插入音频文件在浏览器中播放音频文件的兼容性问题
来源:易贤网 阅读:917 次 日期:2016-06-23 09:12:04
温馨提示:易贤网小编为您整理了“在html中插入音频文件在浏览器中播放音频文件的兼容性问题”,方便广大网友查阅!

下面谈谈本人在html中插入音频文件,经过我的本地测试总结的一些问题(播放mp3文件):

1、<embed type=audio/mp3 src= autostart=true loop=false></embed>

问题:ie8上正常(通过media player插件来播放)但在ie6和ie7上不会播放

firefox上要安装quicktime插件才能播放

chrome通过将其转化成html5上的<vidio>标签播放,能播放但会使整个屏幕蓝屏

opera不会自动播放

2、<embed type=audio/midi src= autostart=true loop=false></embed>

问题:ie6,ie7上不会正常播放,ie8正常

firefox上正常

chrome上要求肮脏quicktime插件才能正常播放

opera不会自动播放

3、<object data= />

问题:在ie6,7上不能播放,ie8会弹出“非正常使用的articx”等字样的提示

firefox上正常

chrome上正常

opera不支持

4、<audio src= type=audio/mp3 />

问题:html5标签 仅chrome支持

5、

代码如下:

<audio autoplay>

<source src= type=audio/mp3 />

<embed src= type=audio/mp3/>

</audio>

问题:ie6,ie7不支持,其余浏览器均支持,opera不能自动播放

6、<embed src=><noembed><bgsound src=></noembed>

问题:ie6,ie7均不支持,其余浏览器均支持,opera不能自动播放

综合以上本人采取了一下方式(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 = navigator.useragent.tolowercase();

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>');

}

中国足彩网信息请查看网页制作
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标