全国统一热线:
028-86758058
18980748058
购买流程
付款方式
常见问题
在线提问
续租服务
购物车(
0
件)
用户名:
密 码:
记住
首 页
HOME
域名注册
DOMAIN
虚拟主机
WEB HOST
成品网站超市
AUTO Site
VPS主机
VPS SERVER
云 主 机
CLOUD HOST
租用托管
SERVER
海外主机
HK HOST
代理专区
AGENT
客服中心
SERVICE
站长教程
SERVICE
欢迎光临西部数据云计算中心,我们将竭诚为您提供最优质的服务!
中文域名
域名转入
域名转出
DNS管理
动态域名
获取域名证书
域名停放
域名过户
集群主机
双线主机
基本主机
港台主机
论坛主机
Linux主机
Vip合租主机
超G型主机
ASP.net主机
Java主机
智能建站主机
网店主机
美国主机
数据库
成品网站超市
智能建站主机
集群VPS主机
国内VPS主机
香港VPS主机
美国VPS主机
云主机介绍
云主机购买
服务器租用
主机托管
常见问题
香港主机
港台主机
美国主机
国内免备案
步骤流程
代理级别
代理合同
代理模式
代理优势
在线申请
产品列表
常见问题
代理商分布图
常见问题
有问必答
跟踪提问
购买流程
产品价格
付款方式
常用软件
网站备案
续租服务
汇款确认
相关文档
联系我们
域名资讯
主机资讯
行业动态
网页制作
php教程
mysql教程
域名资讯
云计算资讯
网络编程
您当前的位置:
首页
>
网络编程
>
网站制作
在html中插入音频文件在浏览器中播放音频文件的兼容性问题
时间:1970-01-01 来源:互联网 作者:佚名
下面谈谈本人在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>');
}
来顶一下
返回首页
推荐资讯
从零开始学ASP.NET-基础篇第1/7页
第一天 学习目的: 掌握最基本的Label、TextBox、Button控件
ASP.NET入门数据篇
对于网站编程的初学者来说,总是会上网找些源码来看,但久而
相关文章
VS2010、VS2008等项目的默认浏览器修改方法(图文)
ASP.net Menu控件在Google Chrome和Safari浏览器下显示
asp.net 客户端浏览器缓存的Http头介绍
asp.net下获取浏览器类型的实现代码
asp.net下用服务器端代码解决浏览器兼容性问题
ASP.NET性能优化之让浏览器缓存动态网页的方法
ASP.NET网站管理系统退出 清除浏览器缓存,Session的代
透过ashx看浏览器服务器运行本质(图解)
判断WebBrowser浏览器网页加载完成的处理方法
asp.net 退出登陆(解决退出后点击浏览器后退问题仍然可
栏目更新
栏目热门
返回首页
关于我们
联系我们
付款方式
价格总览
资讯中心
友情链接
媒体关注
有问必答
投诉建议
网站备案
《中华人民共和国增值电信业务经营许可证》编号:川B2-20080058号
官方网址:
xibushuju.com
西部数据
Copyright © 2002~2015
天府快车
版权所有
电话总机:
028-86758058
(50线) 传真:
028-86758058