audio标签在火狐双击关闭标签本地可以播放音乐,上传到网站火狐双击关闭标签打开闪现1下就没了

本帖子已过去太久远了,不再提供回复功能。在html中插入音频文件在浏览器中播放音频文件的兼容性问题
来源:易贤网&& 阅读:2687 次&&日期: 16:59:05
温馨提示:易贤网小编为您整理了“在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支持
&audio autoplay&
&source src="" type="audio/mp3" /&
&embed src="" type="audio/mp3"/&
问题: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-E95"&&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&
&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-E95"&&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&');
jQuery('#__alert_sound').html('&embed src="/sounds/alert/1.mp3" type="audio/mp3" hidden="true" loop="false" mastersound&&/embed&');
更多信息请查看
更多信息请查看
【】&&&&&【点此处查询各地各类考试咨询QQ号码及交流群】
易贤网手机网站地址:
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
相关阅读 & & &
&&& &nbsp&nbsp&nbsp会员注册
本站不参与评论!()
自觉遵守:爱国、守法、自律、真实、文明的原则
尊重网上道德,遵守中华人民共和国各项有关法律法规
严禁发表危害国家安全,破坏民族团结、国家宗教政策和社会稳定,含侮辱、诽谤、教唆、淫秽等内容的评论
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
您在本站发表的评论,本站有权保留、转载、引用或者删除
参与本评论即表明您已经阅读并接受上述条款2015年7月 Web 开发大版内专家分月排行榜第三
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。2013年3月 Web 开发大版内专家分月排行榜第三
2013年3月 Web 开发大版内专家分月排行榜第三
2013年3月 Web 开发大版内专家分月排行榜第三
2013年3月 Web 开发大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。

我要回帖

更多关于 audio播放音乐 的文章

 

随机推荐