IE8下实现视频播放 IE8下实现MP4播放 IE8 MP4 IE 兼容 MP4

废话不多少,IE8 下兼容MP4  我查资料 搞了多半天,现在有 两种写法,一种 调用 windows 自带播放器 MediaPlayer 播放 请参考第二种写法,

一种调用flash播放 参考第一种写法。

还有一种 兼容video的写法  没测试,嫌麻烦 链接如下 ,经测试 不行。

重点说一下 第二种 一个是<object > 标签 一个是embed 标签 是为了兼容更多浏览器。

<!--播放flash 写法 begin-->
<!--<embed allowscriptaccess="sameDomain" allowNetworking="all" invokeurls="true" src="flash路径.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"
quality="high" autostart="0" wmode="direct"
width="100%" height="100%"
align="middle"
allowFullScreen="true"
allowScriptAccess="always"
scale="showall"
FlashVars="">-->
<!--播放flash 写法 end-->

<!--IE9及以上写法 begin-->
<video id="video" controls="controls">
<source id="videoSrc" src="路径.mp4" type="video/mp4" />
</video>
<!--IE9及以上写法 end-->


<!--IE8 播放MP4写法1 begin-->
<!--<embed id="flash" allowscriptaccess="sameDomain" allowNetworking="all" invokeurls="true" src="路径.mp4" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"
quality="high" autostart="0" wmode="direct"
width="100%" height="100%"
align="middle"
allowFullScreen="true"
allowScriptAccess="always"
scale="showall"
FlashVars="">-->
<!--IE8 播放MP4写法1 end-->


<!--IE8 播放MP4写法2 begin-->
<p id="flash" style="text-align: center;display:none ">
<object id="MediaPlayer"
classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="800"
height="600" standby="Loading Windows Media Player components…"
type="application/x-oleobject"
codebase=" style="color:#0000CC;">
<param name="FileName" value="路径.mp4">
<param name="AutoStart" value="true">
<param name="ShowControls" value="true">
<param name="BufferingTime" value="2">
<param name="ShowStatusBar" value="true">
<param name="AutoSize" value="true">
<param name="InvokeURLs" value="false">
<param name="AnimationatStart" value="1">
<param name="TransparentatStart" value="1">
<param name="Loop" value="1">
<embed type="application/x-mplayer2" src="路径.mp4"
name="MediaPlayer" autostart="1" showstatusbar="1" showdisplay="1"
showcontrols="1" loop="0" videoborder3d="0"
pluginspage=""
width="800" height="600"></embed>
</object>
</p>
<!--IE8 播放MP4写法2 end-->

 

 

动态生成 src 写法如下

if (ieVersion == 'IE8.0') {

$("#video").hide();
var flash="";
flash += "<embed id='flash' style='width:100%;height:" + height + "px;' allowscriptaccess='sameDomain' allowNetworking='all' invokeurls='true' ";
flash += "src='" + src + "' ";
flash +="pluginspage='http://www.macromedia.com/go/getflashplayer' ";
flash +="type='application/x-shockwave-flash' ";
flash +="quality='high' autostart='0' wmode='direct' ";
flash +="width='100%' height='100%' ";
flash +="align='middle'";
flash +="allowFullScreen='true' ";
flash +="allowScriptAccess='always' ";
flash +="scale='showall' ";
flash +="FlashVars=''/> ";
$("#flash").html(flash);
$("#flash").show();

} else {

$("#video").attr("height", height+"px");
$("#videoSrc").attr("src", src + queryStr("path"));
}

-------------------------------------------------------------------我是割鸡 割鸡 -------------------------------------------------------------------

页面全部代码如下

<!DOCTYPE html>
<!-- saved from url=(0052)http://cdn-dl.insta360.com/event/event-bikini/flash/ -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试player</title>
<meta charset="UTF-8">
<!--支持IE8版本 jq-->
<script src="../../Resource/jquery-1.10.2.js"></script>
<script src="../../Resource/jquery-1.10.2.min.js"></script>
<script src="../../Resource/jquery.cookie.min.js"></script>
<style type="text/css" media="screen">
html,
body {
height: 100%;
background-color: #ffffff;
}

body {
margin: 0;
padding: 0;
overflow: hidden;
}

#flashContent {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="flashContent">
<!--播放flash 写法 begin-->
<!--<embed allowscriptaccess="sameDomain" allowNetworking="all" invokeurls="true" src="flash路径..swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"
quality="high" autostart="0" wmode="direct"
width="100%" height="100%"
align="middle"
allowFullScreen="true"
allowScriptAccess="always"
scale="showall"
FlashVars="">-->
<!--播放flash 写法 end-->

<!--IE9及以上写法 begin-->
<video id="video" controls="controls">
<source id="videoSrc" src="路径.mp4" type="video/mp4" />
</video>
<!--IE9及以上写法 end-->
<!--IE8 播放MP4写法1 begin-->
<!--<embed id="flash" allowscriptaccess="sameDomain" allowNetworking="all" invokeurls="true" src="路径.mp4" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"
quality="high" autostart="0" wmode="direct"
width="100%" height="100%"
align="middle"
allowFullScreen="true"
allowScriptAccess="always"
scale="showall"
FlashVars="">-->
<!--IE8 播放MP4写法1 end-->


<!--IE8 播放MP4写法2 begin-->
<p id="flash" style="text-align: center;display:none ">
<object id="MediaPlayer"
classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="800"
height="600" standby="Loading Windows Media Player components…"
type="application/x-oleobject"
codebase=" style="color:#0000CC;">
<param name="FileName" value="路径.mp4">
<param name="AutoStart" value="true">
<param name="ShowControls" value="true">
<param name="BufferingTime" value="2">
<param name="ShowStatusBar" value="true">
<param name="AutoSize" value="true">
<param name="InvokeURLs" value="false">
<param name="AnimationatStart" value="1">
<param name="TransparentatStart" value="1">
<param name="Loop" value="1">
<embed type="application/x-mplayer2" src="路径.mp4"
name="MediaPlayer" autostart="1" showstatusbar="1" showdisplay="1"
showcontrols="1" loop="0" videoborder3d="0"
pluginspage=""
width="800" height="600"></embed>
</object>
</p>
<!--IE8 播放MP4写法2 end-->
</div>
<script type="text/javascript">
$(function () {
//判断IE 版本1E8及以下调用flash ie9以上使用Video
checkIEVersion2();
});
function checkIEVersion2() {
var ieVersion = checkBrowerVersion2();
var height = document.documentElement.clientHeight - 185;
var src = "路径.mp4";
if (ieVersion == 'IE8.0') {
$("#video").hide();
var flash="";
flash += "<embed id='flash' style='width:100%;height:" + height + "px;' allowscriptaccess='sameDomain' allowNetworking='all' invokeurls='true' ";
flash += "src='" + src + "' ";
flash +="pluginspage='http://www.macromedia.com/go/getflashplayer' ";
flash +="type='application/x-shockwave-flash' ";
flash +="quality='high' autostart='0' wmode='direct' ";
flash +="width='100%' height='100%' ";
flash +="align='middle'";
flash +="allowFullScreen='true' ";
flash +="allowScriptAccess='always' ";
flash +="scale='showall' ";
flash +="FlashVars=''/> ";
$("#flash").html(flash);
$("#flash").show();
} else {
$("#video").attr("height", height+"px");
$("#videoSrc").attr("src", src + queryStr("path"));
}
//if (ieVersion.indexOf("IE") == -1) {
// //alert("请使用IE浏览器");
// //alertMessage(867);//请使用IE内核浏览器
// return false;
//}

//if (ieVersion == 'IE7.0') {
// //alert("请使用IE8及以上版本浏览器。");
// return false;
//}


}
function checkBrowerVersion2() {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/rv:([\d.]+)\) like gecko/)) ? Sys.ie = s[1] :
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

var version = "";
if (Sys.ie)
version = "IE" + Sys.ie;

if (Sys.firefox)
version = 'Firefox' + Sys.firefox;
if (Sys.chrome)
version = 'Chrome' + Sys.chrome;
if (Sys.opera)
version = 'Opera' + Sys.opera;
if (Sys.safari)
version = 'Safari' + Sys.safari;
return version;
}

 

</script>
</body>
</html>

posted @ 2021-03-10 14:50  断剑重铸之日  阅读(1245)  评论(0编辑  收藏  举报