目录
1.html部分:play.html
2.引入的 vodplay.css
3.引入的js文件
1.html部分:play.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http: //www.w3.org/1999/xhtml"> <head>
<meta charset="UTF-8">
<title>play</title>
<link rel="stylesheet" href="../css/vodplay.css" />
</head>
<bodybgcolor="transparent"leftmargin="0"topmargin="0"marginwidth="0"marginheight="0"style="background-color:transparent;">
<div class="box">
<!--音量-->
<div class="voice" id="volumeDiv">
<div class="title3">
<span id="volumepercent">50%</span>
</div>
<!--进度条-->
<!--voiceBar1原生样式-->
<div class="voiceBar1">
<!--voiceBar2为进度条移动样式-->
<div class="voiceBar2" id="volumecolorbar"></div>
</div>
<!--喇叭-->
<div class="voicePic"></div>
</div>
<!--断点续播操作-->
<div class="playBack" id="progressdiv">
<div class="title2" id="question">
<span>按“返回”键可以从头看</span>
</div>
<div class="tishi" id="playingtimediv">
<span id="playingtime">20:35</span>
</div>
<!--暂停-->
<div class="playPic" id="playstatus"></div>
<!--播放 display: none;-->
<div class="suspended"></div>
<!--进度条-->
<!--progressBar1-->
<div class="progressBar1"></div>
<!--progressBar2为进度条移动样式-->
<div class="progressBar2" id="progressbar"></div>
<div class="playTime">
<span id="playtime">20:35/110:49</span>
</div>
<div class="tishi2">
<span id="playprogramname">正在播放:大话西游之爱你一万年</span>
</div>
</div>
<!--暂停时遮罩-->
<div class="zhezhao" id="pauseDiv">
<div class="mask"></div>
<div class="maskPic">
<img id="img" src="../images/Eimg/player_icon_pause1.png" />
</div>
</div>
<!--退出提示-->
<div class="exit">
<div class="mask"></div>
<div class="inform">
<div class="inforHeader">提示</div>
<div class="inforMain">
<div class="word">您确定要退出播放吗?</div>
<div class="advertising">
<!-- <img src="../images/Eimg/popup_p1.jpg"/> -->
<!-- <img src="../images/Eimg/popup_p1.jpg"/> -->
</div>
<div class="button">
<!--buttonSel为焦点样式-->
<div class="exitbutton determine buttonSel" id="sureBtn">取消</div>
<div class="exitbutton cancel">确定</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="../js/util/config.js"></script>
<script src="../js/util/fun.js"></script>
<script src="../js/util/ajaxMy.js"></script>
<script src="../js/play/media.js"></script>
<script src="../js/play/keyPress.js"></script>
<script src="../js/play/master.js"></script>
<script src="../js/play/common.js"></script>
<script src="../js/play/back.js"></script>
<script src="../js/play/vodplay.js"></script>
</html>
<!-- 二、通过iframe框架调用代码 -->
<!-- <div style="position:absolute;left: 165px; top: 17px; width:320px;
height:206px;z-index:99;overflow:hidden;"> <iframe name="if_smallscreen"
id="if_smallscreen" width="320" height="206" src="hwvideo.php?width=320&height=206&left=165&top=17"
frameborder="no" scrolling="no"></iframe></div> -->
<!-- 三、需要注意的事项 (1)如果有背景图片,请保持视频播放区域的背景图片透明;
(2)层必须设定宽高,详见第二点代码;
(3)设置视频位置必须用到setVideoDisplayArea方法;
(4)<body>必须写为<bodybgcolor="transparent" leftmargin="0" topmargin="0" marginwidth="0"marginheight="0"
style="background-color: transparent;position:absolute;z-index:0;">,
至少保留background-color:transparent以及bgcolor="transparent";
(5)视频跨页播放的问题 -->
<!-- 页面已经跳转到另一个页面去了,而视频仍在播放,若是用iframe嵌套播放的话,
则在视频返回的js里加上代码:var if_smallscreen = document.getElementByIdx_x("if_smallscreen");
if_smallscreen.mp.stop(); 其中if_smallscreen为iframe的对象id若并未用iframe嵌套播放,则参见第一点代码 -->
2.引入的 vodplay.css
body{ line-height:28px; color:#fff;font-size:28px;font-family:"Microsoft YaHei";}
input,textarea,select{font-size:100%;font-family:inherit;outline:none;}
body,h1,h2,h3,h4,h5,h6,p,ul,ol,form{margin:0;}
h4,h5,h6{font-size:1em;}
img{border:0;}
ul,ol{padding:0; list-style-type:none;margin: 0;}
li{padding:0;}
.dn{display: none;}
.vh{visibility: hidden;}
.o0{opacity: 0;}
/*点播播放页*/
.box{
width: 1280px;
height: 720px;
}
.operation{
width: 1278px;
height: 180px;
position: absolute;
top: 537px;
left: 0px;
background: url(../images/Eimg/player_mengban.png) no-repeat;
visibility:hidden;
}
.operation .point{
position: absolute;
top: 3px;
width: 14px;
height: 14px;
background-color: #ffffff;
border-radius: 50%;
}
.operation .title1{
position: absolute;
top: -9px;
left:20px;
}
.operation .title1 span{
margin-left: 5px;
font-size: 17px;
color: #FFFFFF;
}
.operation .seriesNum{
position: absolute;
top: 35px;
left: 20px;
}
.operation .seriesNum .seriesList{
display: inline-block;
text-align: center;
line-height: 64px;
width: 64px;
height: 64px;
background-color:#38383C;
opacity: 0.5;
margin-left: 10px;
}
.operation .seriesNum .seriesList span{
font-size: 24px;
color: #FFFFFF;
}
.operation .seriesNum .seriesSel{
background-color: rgb(232,130,45);
opacity: 1;
}
.operation .sets{
position: absolute;
top:115px;
left: 5px;
}
.operation .sets span{
font-size: 24px;
display: inline-block;
text-align: center;
line-height: 40px;
width:126px;
height:40px;
margin-left: 25px;
background-color:#38383C;
opacity: 0.7;
}
.operation .setSel{
color: rgb(232,130,45);
opacity: 1;
}
/*音量*/
.voice{
position:absolute;
left: 1150px;
top: 70px;
visibility:hidden;
}
.voice .title3{
position: absolute;
top: 170px;
left: -42px;
}
.voice .title3 span{
color:rgb(232,130,45) ;
font-size: 14px;
}
.voice .voiceBar1{
position: relative;
width: 1px;
height: 400px;
background-color: #1A120E;
}
.voiceBar1 .voiceBar2{
position: absolute;
left: 0px;
bottom: 0;
width: 1px;
height: 200px;
background-color: rgb(232,130,45);
}
.voice .voicePic{
left: -8px;
width: 20px;
height: 20px;
position: absolute;
top: 420px;
background: url(../images/Eimg/player_icon_volume.png) no-repeat;
}
/*断点续播*/
.playBack{
background: url(../images/Eimg/player_mengban.png) no-repeat;
width: 1278px;
height: 180px;
position: absolute;
top:539px;
left: 0px;
visibility:hidden;
/*display: none;*/
}
.playBack .title2{
text-align: center;
line-height: 50px;
position: absolute;
top: 0;
left: 400px;
width: 422px;
height: 50px;
border: 2px solid rgb(232,130,45);
background-color:#1a120e;
border-radius: 25px;
opacity: 0.8;
visibility:hidden;
}
.playBack .title2 span{
font-size: 24px;
color: #AFAEAE;
}
.playBack .progressBar1{
position: relative;
top: 100px;
left: 100px;
height: 1px;
width:1000px;
background-color: #AFAEAE;
}
.playBack .progressBar2{
position: absolute;
top: 100px;
left: 100px;
height: 1px;
width:550px;
background-color:rgb(232,130,45);
}
.playBack .tishi{
text-align: center;
line-height: 24px;
width: 82px;
height: 24px;
border-radius: 15px;
position: absolute;
top: 60px;
left: 280px;
background-color:rgb(232,130,45);
padding-bottom: 7px;
}
.playBack .playPic{
width: 20px;
height: 26px;
position: absolute;
top: 88px;
left: 50px;
background: url(../images/Eimg/player_icon_playing.png) no-repeat;
}
.playBack .suspended{
width: 20px;
height: 26px;
position: absolute;
top: 88px;
left: 50px;
background: url(../images/Eimg/player_icon_pause.png) no-repeat;
display: none;
}
.playBack .tishi span,.tishi2 span{
font-size: 18px;
}
.playBack .playTime{
position: absolute;
top: 79px;
left: 1124px;
}
.playBack .playTime span{
font-size: 14px;
}
.playBack .tishi2{
position: absolute;
top: 108px;
left: 98px;
}
.zhezhao{
visibility:hidden;
}
.mask {
position: absolute;
top: 0px;
left: 0px;
width: 1280px;
height: 720px;
background: #000;
opacity: 0.7;
}
.zhezhao .maskPic{
position:absolute;
top:30%;
left:40%;
z-index: 9999;
}
.exit{
display: none;
}
.exit .inform{
width:400px;
height: 220px;
border-radius: 20px;
background-color:#2a2f3a;
opacity: 0.9;
position:absolute;
top:30%;
left:35%;
z-index: 9999;
}
.exit .inform .inforHeader{
/* background: url(../images/Eimg/popup_icon_prompt.png) no-repeat 15px 5px; */
width:400px;
height:60px;
text-align: center;
line-height: 60px;
font-size: 30px;
background-color:#1e2127;
opacity: 0.8;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
}
.inforMain .word{
width: 400px;
text-align: center;
font-size: 24px;
/* padding-left: 25px; */
padding-top: 25px;
}
.inforMain .advertising{
margin-left: 25px;
margin-top: 25px;
}
.inforMain .advertising img:nth-child(2){
margin-top: 45px;
margin-left: 38px;
}
.inforMain .button{
text-align: center;
margin-top: 30px;
/* margin-left: 38px; */
}
.inforMain .button .determine,.cancel{
font-size: 24px;
display: inline-block;
text-align: center;
line-height: 45px;
background-color: #2b2424;
width: 125px;
height: 45px;
border-radius:30px;
/* margin-left: 50px; */
}
.determine {
margin-right: 20px;
}
.inforMain .button .buttonSel{
background-color: rgb(232,130,45);
}
3.引入的js文件
3.1 config.js 配置的接口请求地址
/**
* 公共路径配置
*/
// 阿里
var baseURL = "http://59.110.50.146:8080/ntms/";
var IMGURL = "http://59.110.50.146";
var VIDEOURL = "http://59.110.50.146";
var PLANFORMTAB = "BD";// 本地
3.2 fun.js
/**
* 获取iptv机顶盒参数
*/
function getIPTVConfig(name) {
return Authentication.CTCGetConfig(name);
}
/**
* 处理url传值
*/
function dealUrl(url) {
var json = {};
if (url.indexOf("?") > -1) {
var arr = url.split("?")[1];
var arrList = url.indexOf("&") > -1 ? arr.split("&") : arr.split("*");
for (var i in arrList) {
json[arrList[i].split("=")[0]] = arrList[i].split("=")[1];
}
}
return json;
}
/**
* 获取需要对url传递的参数,并处理
* needParam需要传递的新参数
* needJumpUrl需要跳转的url
* oldUrl原页面的url
* addIcon拼接参数的符号
*/
function dealParam(needParam, needJumpUrl, oldUrl, addIcon) {
var oldUrlParam = dealUrl(oldUrl);
for (var key in oldUrlParam) {
if (!needParam[key]) {
needParam[key] = oldUrlParam[key];
}
}
for (var i in needParam) {
if (needJumpUrl.indexOf("?") > -1) {
needJumpUrl += addIcon + i + "=" + needParam[i];
} else {
needJumpUrl += "?" + i + "=" + needParam[i];
}
}
return needJumpUrl;
}
/**
* 获取时间戳
*/
function getTime() {
var time = Date.parse(new Date()).toString();//获取到毫秒的时间戳,精确到毫秒
time = time.substr(0, 10);//精确到秒
return time;
}
/**
* 焦点事件--放大效果
*/
function focusScale(element) {
element.classList.add("onFocus");
}
/**
* 取消--焦点事件--放大效果
*/
function blurScale(element) {
element.classList.remove("onFocus");
}
/**
* 提示消息
*/
function showMessage(info) {
var elementDiv = document.createElement("div");
var elementDivClass = document.createAttribute("class");
elementDivClass.value = "message_content";
elementDiv.setAttributeNode(elementDivClass);
var txtdiv = document.createTextNode(info);
elementDiv.appendChild(txtdiv);
var elementDivId = document.createAttribute("id");
elementDivId.value = "message_content";
elementDiv.setAttributeNode(elementDivId);
// var message_content = document.getElementById("message_content");
// var infoDiv = document.createElement("div");
// var txtdiv = document.createTextNode(info);
// infoDiv.appendChild(txtdiv);
// var infoDivClass = document.createAttribute("class");
// infoDivClass.value = "message_info";
// infoDiv.setAttributeNode(infoDivClass);
// message_content.appendChild(infoDiv);
document.body.appendChild(elementDiv);
var elementMarkDiv = document.createElement("div");
var elementMarkDivClass = document.createAttribute("class");
elementMarkDivClass.value = "message_mask";
elementMarkDiv.setAttributeNode(elementMarkDivClass);
var elementDivMarkId = document.createAttribute("id");
elementDivMarkId.value = "message_mask";
elementMarkDiv.setAttributeNode(elementDivMarkId);
document.body.appendChild(elementMarkDiv);
var message_mask = document.getElementById("message_mask");
var message_content = document.getElementById("message_content");
setTimeout(function () {
document.body.removeChild(message_mask);
document.body.removeChild(message_content);
}, 1000);
}
/**
* 添加log
*/
function recordLog(param) {
if (!sessionStorage.USERID) {
return;
}
// 用户账号
if (sessionStorage.USERID) {
param.userId = sessionStorage.USERID;
}
// 用户32位key
if (sessionStorage.USERKWY) {
param.userKey = sessionStorage.USERKWY;
}
// 用户所属平台
if (sessionStorage.USERBELONGINGPLATFORMu) {
param.userBelongingPlatform = sessionStorage.USERBELONGINGPLATFORMu; // 用户所属平台
}
// 所属城市
if (sessionStorage.USERbELONGINGrEGION) {
param.userBelongingRegion = sessionStorage.USERbELONGINGrEGION; // 用户所属区域
}
// 机顶盒mac地址
if (sessionStorage.IASPMAC) {
param.iaspmac = sessionStorage.IASPMAC;
}
// 登录ip地址
if (sessionStorage.IASPIP) {
param.iaspip = sessionStorage.IASPIP;
}
// 所属区域
if (sessionStorage.AREAID) {
param.areaId = sessionStorage.AREAID;
}
// 业务账号
if (sessionStorage.IASPADSL) {
param.iaspadsl = sessionStorage.IASPADSL;
}
ajax({
method: "post",
data: param,
url: "iptv/insertIptvLog",
success: function (res) {
},
error: function (e) {
console.log(e);
},
});
}
/**
* 实时显示时间--时分秒
*/
function showTime() {
setInterval(function () {
var date = new Date();
var h = date.getHours(); //获取小时
var m = date.getMinutes(); //获取分钟
m = m < 10 ? "0" + m : m;
var s = date.getSeconds(); //获取秒
s = s < 10 ? "0" + s : s;
var d = document.getElementById('Date');
d.innerHTML = h + ':' + m + ':' + s;
}, 1000)
}
/**
* 实时显示时间--年月日时分秒
*/
function showTimeAll(id, type) {
setInterval(function () {
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1)
: date.getMonth() + 1;
var day = date.getDate() < 10 ? "0" + date.getDate() : date
.getDate();
var h = date.getHours(); //获取小时
var m = date.getMinutes(); //获取分钟
m = m < 10 ? "0" + m : m;
var s = date.getSeconds(); //获取秒
s = s < 10 ? "0" + s : s;
var d = date.getDay();
var weekday = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
var w = weekday[d];
var d = document.getElementById(id);
if (type == 'ymd') {
d.innerHTML = year + "-" + month + "-" + day;
}
if (type == 'hms') {
d.innerHTML = h + ':' + m + ':' + s;
}
if (type == 'hm') {
d.innerHTML = h + ':' + m;
}
if (type == 'w') {
d.innerHTML = w;
}
}, 1000)
}
/**
* 更新节目历史
*/
function updateProgram(primaryId, schedule, USERID) {
var param = {
programId: primaryId,
schedule: schedule,
userId: USERID, // 用户账号,
};
ajax({
method: "post",
data: param,
url: "iptv/updateHistory",
success: function (res) { },
error: function (e) {
console.log(e);
},
});
}
/**
* 电信跳转详情
*/
function DXJump(primaryId, USERID, id) {
// 查询节目详情
var param = {
"primaryId": primaryId,
"userBelongingPlatform": "HW"
};
ajax({
method: "post",
data: param,
url: "iptv/programInfo",
success: function (res) {
var data = JSON.parse(res).rows[0];
// 添加Log
var param = {
logName: "视频播放页",
programName: data.name,
columnName: data.columnName,
categoryName: data.categoryName,
programId: primaryId,
userId: USERID, // 用户账号
};
if (id && id.indexOf("tab") == -1) {
param.positionId = id;
}
recordLog(param);
// 播放
var param = {
'seriesflag': data.seriesFlag, // 0电影或1电视剧标识
'longTitle': data.longTitle, //列表形式 0 长标题详情页形式,1 如果是电影传空字符串
'showBackground': 0 //模糊背景 0 不显示 1 显示
}
// 电影
if (data.seriesFlag == '0') {
param.sequenceCode = ''; //华为子集id
param.code = data.zteCode; // 子集code
}
// 电视剧
if (data.seriesFlag == '1') {
param.code = data.dramaId; //剧头id
}
jsObj.eventFromJS("{ 'type':1, 'data':" + JSON.stringify(param) +
",'spid':'BFSX'}");
return;
},
error: function (e) {
console.log(e);
},
});
}
/**
* 本地或者联通跳转详情
* primaryId节目ID
* USERID用户账号
* id
* flag 跳转页面flag
* jumpUrl跳转地址
*/
function BDOrLTJump(primaryId, USERID, id, flag, backUrl) {
// 查询节目详情
var param = {
"primaryId": primaryId,
"userBelongingPlatform": "HW"
};
ajax({
method: "post",
data: param,
url: "iptv/programInfo",
success: function (res) {
var data = JSON.parse(res).rows[0];
// 主页面详情页
if (flag == "homeDetail") {
// 添加Log
var param = {
logName: "视频详情页",
programName: data.name,
columnName: data.columnName,
categoryName: data.categoryName,
programId: primaryId,
userId: USERID, // 用户账号
};
if (id && id.indexOf("tab") == -1) {
param.positionId = id;
}
recordLog(param);
window.location.href = '../pages/detailPlay.html?value=' + data.columnCode +
'&primaryId=' + primaryId + '&backUrl=' + backUrl;
return;
}
// 旅游页详情页
if (flag == "travleDeatil") {
// 添加Log
var param = {
logName: "旅游详情页",
programName: data.name,
columnName: data.columnName,
categoryName: data.categoryName,
programId: primaryId,
userId: USERID, // 用户账号
};
recordLog(param);
window.location.href = jumpUrl;
// window.location.href = './detail.html';
return;
}
}
})
}
3.3 ajaxMy.js 原生JavaScript封装的ajax
/* 封装ajax函数
* @param {string}opt.method http连接的方式,包括POST和GET两种方式
* @param {string}opt.url 发送请求的url
* @param {boolean}opt.async 是否为异步请求,true为异步的,false为同步的
* @param {object}opt.data 发送的参数,格式为对象类型
* @param {function}opt.success ajax发送并接收成功调用的回调函数
*/
/*1常规封装*/
function ajax(opt) {
opt = opt || {};
opt.method = opt.method.toUpperCase() || "GET"; //GET:用"GET"方式发送数据,只能256KB;POST:用"POST"方式发送数据,可以大到4MB
opt.url = opt.url || "";
opt.async = opt.async || true; //同步异步
opt.dataType = opt.dataType || "text"; //所传的数的数据类型
opt.contentType = opt.contentType || "application/x-www-form-urlencoded; charset=utf-8"; //默认表单格式 opt.dataType='json'
opt.data = opt.data || null;
var xmlHttp = getXmlHttp(); //获取XML 对象
// xmlHttp.setRequestHeader('Access-Control-Allow-Origin', '*',);
// xmlHttp.setRequestHeader('Access-Control-Allow-Methods','GET, POST, PUT');
var postData = getAjaxParama(opt.data); //data
if (opt.contentType === "application/json;charset=utf-8" && opt.dataType === "json") {
postData = JSON.stringify(opt.data); //转化为字符串
}
if (opt.method === 'POST') {
xmlHttp.open(opt.method, baseURL + opt.url, opt.async);
xmlHttp.setRequestHeader('Content-Type', opt.contentType); //而POST请求需要设置请求头,用来传递参数
} else if (opt.method === 'GET') {
postData = opt.url.indexOf("?") >= 0 ? "&" + postData : "?" + postData; //GET请求,参数是拼接到url上面;
xmlHttp.open(opt.method, baseGetUrl + opt.url + postData, opt.async);
xmlHttp.setRequestHeader('Content-Type', "application/json;charset=utf-8"); //而POST请求需要设置请求头,用来传递参数
xmlHttp.setRequestHeader('Access-Control-Allow-Origin', "*");
postData = null; //重置参数
}
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
var status = xmlHttp.status;
if (status >= 200 && status < 300) {
opt.success && opt.success(xmlHttp.response);
} else {
opt.error && opt.error(status);
}
}
};
xmlHttp.send(postData);
function getXmlHttp() {
var obj = null;
//非IE浏览器创建XmlHttpRequest对象
if (window.XMLHttpRequest) obj = new XMLHttpRequest();
//IE浏览器创建XmlHttpRequest对象
if (window.ActiveXObject) {
try {
obj = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
try {
obj = new ActiveXObject("msxml2.XMLHTTP");
} catch (ex) { }
}
}
return obj;
}
function getAjaxParama(data) {
var params = [];
for (var key in data) {
params.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
}
return params.join('&'); //添加&字符串
}
}
function createCORS(method, url) {
var xhr = new XMLHttpRequest();
if ('withCredentials' in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != 'undefined') {
var xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
/* ajax请求get
* @param url string 请求的路径
* @param query object 请求的参数query
* @param succCb function 请求成功之后的回调
* @param failCb function 请求失败的回调
* @param isJson boolean true: 解析json false:文本请求 默认值true
*/
function ajaxGet(url, query, succCb, failCb, isJson) {
// ajaxGet("authbilling/authenticationIptv_getTemptokenByUserid.do", param)
url = baseURL + url;
// 拼接url加query
if (query) {
var parms = getAjaxParama(query);
url += '?' + parms;
// console.log('-------------',url);
}
// 1、创建对象
var ajax = new XMLHttpRequest();
// 2、建立连接
// true:请求为异步 false:同步
ajax.open("GET", url, true);
// var request = createCORS('get', url);
// if (request) {
// request.onload = function () {
// };
// request.send();
// }
ajax.setRequestHeader("Origin", "*");
ajax.setRequestHeader("Access-Control-Allow-Origin", "*");
// // 响应类型
ajax.setRequestHeader('Access-Control-Allow-Methods', '*');
// // 响应头设置
ajax.setRequestHeader('Access-Control-Allow-Headers', 'x-requested-with,content-type');
ajax.withCredentials = true;
var request = createCORS('get', url);
if (request) {
request.onload = function () {
};
request.send();
}
// 3、发送请求
// ajax.send(null);
// 4、监听状态的改变
ajax.onreadystatechange = function () {
if (ajax.readyState === 4) {
if (ajax.status === 200) {
// 用户传了回调才执行
// isJson默认值为true,要解析json
if (isJson === undefined) {
isJson = true;
}
var res = isJson ? JSON.parse(ajax.responseText == "" ? '{}' : ajax.responseText) : ajax.responseText;
succCb && succCb(res);
} else {
// 请求失败
failCb && failCb();
}
}
}
function getAjaxParama(data) {
var params = [];
for (var key in data) {
params.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
}
return params.join('&'); //添加&字符串
}
}
// loadScript(
// 'http://218.24.37.2:89/authbilling/authenticationIptv_getTemptokenByUserid.do?time=1622014711370&userid=02405285596a1&riddle=35b27271f9b7cc2a50c7923a187451bd&callback=callbackMethod'
// );
// function callbackMethod(data) {
// console.log(data)
// }
// 通过动态创建script来请求
function loadScript(url) {
var head = document.head || document.getElementByTagName('head')[0];
var script = document.createElement('script');
script.onload = script.onreadystatechange = function () {
if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
script.onload = script.onreadystatechange = null;
}
};
head.append(script);
script.src = url;
}
3.4 media.js
var urlData = dealUrl(window.location.href);
var USERID = sessionStorage.USERID; // 用户账号
getInit(urlData.primaryId);
/**
* 获取节目详细信息
*/
function getInit(primaryId) {
var param = {
primaryId: primaryId,
userBelongingPlatform: "GW"
};
ajax({
method: "post",
data: param,
url: "iptv/programInfo",
success: function (res) {
var data = JSON.parse(res).rows[0];
document.getElementById("playprogramname").innerText = data.name;
// 添加Log
var param = {
logName: "视频播放页",
programName: data.name,
columnName: data.columnName,
categoryName: data.categoryName,
programId: primaryId,
};
recordLog(param);
if (data.zteCode && data.zteCode != "无") {
playInit(data.zteCode);
}
},
error: function (e) {
console.log(e);
},
});
}
/**
* 播放初始化
*/
function playInit(url) {
mediaStr = '[{mediaUrl:"' + VIDEOURL + url + '",';
mediaStr += 'mediaCode: "jsoncode1",';
mediaStr += "mediaType:2,";
mediaStr += "audioType:1,";
mediaStr += "videoType:1,";
mediaStr += "streamType:1,";
mediaStr += "drmType:1,";
mediaStr += "fingerPrint:0,";
mediaStr += "copyProtection:1,";
mediaStr += "allowTrickmode:1,";
mediaStr += "startTime:0,";
mediaStr += "endTime:20000,";
mediaStr += 'entryID:"jsonentry1"}]';
mp = new MediaPlayer(); //新建一个mediaplayer对象
instanceId = mp.getNativePlayerInstanceID(); //读取本地的媒体播放实例的标识
play();
}
/**
* 播放
*/
function play() {
initMediaPlay(); //首先初始话mediaplayer对象
mp.playFromStart(); //从头开始播放
var process = urlData.schedule.replace("%", "") * 1;
if (urlData.schedule && process != 0) {
setTimeout(function () {
var duration = parseInt(mp.getMediaDuration(), 10);
var currenttime = parseInt(mp.getCurrentPlayTime(), 10);
var playTimer = (duration * process) / 100;
mpjump(Math.round(playTimer));
document.getElementById("playprogramname").innerText = playTimer;
}, 500);
}
}
/**
* 初始化
*/
function initMediaPlay() {
var playListFlag = 0; //Media Player 的播放模式。 0:单媒体的播放模式 (默认值),1:播放列表的播放模式
var videoDisplayMode = 1; //MediaPlayer 对象对应的视频窗口的显示模式. 1:全屏显示2: 按宽度显示,3: 按高度显示
var height = 720;
var width = 1280;
var left = 0; // 自定义尺寸必须指定
var top = 0; // 自定义尺寸必须指定
var muteFlag = 0; //0: 设置为有声 (默认值) 1: 设置为静音
var subtitleFlag = 0; //字幕显示
var videoAlpha = 0; //视频的透明度
var cycleFlag = 0;
var randomFlag = 0;
var autoDelFlag = 0;
var useNativeUIFlag = 1;
//初始化mediaplayer对象
mp.initMediaPlayer(
instanceId,
playListFlag,
videoDisplayMode,
height,
width,
left,
top,
muteFlag,
useNativeUIFlag,
subtitleFlag,
videoAlpha,
cycleFlag,
randomFlag,
autoDelFlag
);
mp.setSingleMedia(mediaStr); //设置媒体播放器播放媒体内容
mp.setAllowTrickmodeFlag(0); //设置是否允许trick操作。 0:允许 1:不允许
mp.setVideoDisplayMode(0);
mp.setVideoDisplayArea(left, top, width, height);
mp.setNativeUIFlag(0); //设置播放器本地UI显示功能 0:允许 1:不允许
mp.setAudioTrackUIFlag(1);
mp.setMuteUIFlag(1);
mp.setAudioVolumeUIFlag(1);
mp.refreshVideoDisplay();
setseriesListParas();
}
/**
* 视频播放完毕后跳转
*/
function isEnd() {
var curTime = mp.getCurrentPlayTime();
var allTime = mp.getMediaDuration();
if (allTime == curTime && curTime != 0) {
clearInterval(z);
// mp.releaseMediaPlayer(instanceId);
// window.location.href = "index.php";
closemedia();
// window.location.href =
// "./detailPlay.html?primaryId=" +
// dealUrl(window.location.href).primaryId +
// "&value=" +
// dealUrl(window.location.href).value;
window.history.go(-1);
update();
}
}
/**
* 更新节目历史
*/
function update() {
var duration = parseInt(mp.getMediaDuration(), 10);
var currenttime = parseInt(mp.getCurrentPlayTime(), 10);
var schedule = currenttime / duration;
if (duration == 0) {
schedule = '0%';
} else {
schedule = Math.round(schedule * 100) + "%";
}
var param = {
programId: dealUrl(window.location.href).primaryId,
schedule: schedule,
// userId: USERID,// 用户账号,
};
updateProgram(param.programId, param.schedule, param.userId);
}
var z = setInterval(isEnd, 2000);
function closemedia() {
mp.stop();
mp.releaseMediaPlayer(instanceId);
// mp.refreshVideoDisplay();
instanceId = -1;
}
function continueplay(time) {
mp.playByTime(1, continuetime, 1);
}
var int;
function tryplay() {
int = setInterval("breakplay()", 5000);
}
function breakplay() {
if (parseInt(mp.getCurrentPlayTime()) >= 360) {
mp.stop();
}
}
3.5 keyPress.js
var pressFlag = true;
function keyBvod(){
var url = "chan_RecordList.jsp";
window.location.href = url;
}
function keyTvod(){
var url = "tvod_progBillByRepertoire.jsp";
window.location.href = url;
}
function keyVod(){
var url = "vod_Category.jsp ";
window.location.href = url;
}
keyBlue = function(){
//var url = "xf_category.html";
//window.location.href = url;
}
function keyFavourite(){
//var url = "favorite.jsp";
//window.location.href = url;
}
keyTrack = function (){EPG.keyTrack();}
keyPageUp = function(){EPG.keyPageUp();}
keyPageDown = function(){EPG.keyPageDown();}
keyIME = function(){}
keyFav = function(){}
keyMore = function(){}
keySearch = function(){}
goUtility = function(){EPG.goUtility(eventJson);}
keyPausePlay = function(){EPG.keyPausePlay();}
keyVolUp = function(){EPG.keyVolUp();}
keyVolDown = function(){EPG.keyVolDown();}
keyChannelUp = function(){EPG.keyChannelUp();}
keyChannelDown = function(){EPG.keyChannelDown();}
keyMute = function(){EPG.keyMute();}
keyFastForward = function(){EPG.keyFastForward();}
keyFastRewind = function(){EPG.keyFastRewind();}
keyPreviewTimesOver = function(){EPG.keyPreviewTimesOver();}
keyPreviewTimesUp = function(){EPG.keyPreviewTimesUp();}
keyStbNoChannel= function(){EPG.keyStbNoChannel();}
keyInfo = function(){EPG.keyInfo();}
keyHelp = function(){EPG.keyHelp();}
keyPos = function(){EPG.keyPos();}
//以下代码为输入数字键中转致直播
var ChannelNum = "";
var showNumTimeOut = -1;
var lineArray = ["_","__","___"];
var lineIndex = 0;
var lineTimeout = -1;
function inputNum(num){
if (playmode == "pause")return ;
// createDiv("channel_num","50px","36px");
ChannelNum = ChannelNum + num;
//没下划线时输入数字的最大长度为3,有下划线时输入的最大长度为下划线的长度
if(ChannelNum.length == 4 || (checkChanNumShow() && ChannelNum.length == (lineIndex+2)))
{
ChannelNum = num + "";
}
// window.frames["EPG"].window.document.getElementById("channel_num").innerText = ChannelNum;
document.getElementById("channel_num").innerText = ChannelNum;
showChanNumDiv("channel_num");
clearTimeout(showNumTimeOut);
clearTimeout(lineTimeout);
showNumTimeOut = setTimeout(function (){
if(!checkChanNumShow() || ChannelNum.length == (lineIndex+1))//判断输入的数字是否等于下划线的长度
{
playChannel();
}
},2000);
}
//上下左右键扩展方法
/* keyUp = function(){}
keyDown = function(){}
keyLeft = function(){}
keyRight = function(){}*/
function closeIframe()
{
document.getElementById("tvmsInfo").style.display = "none";
document.getElementById("close").blur();
}
function playChannel()
{
if(ChannelNum == "")
{
return;
}
if(typeof(changeChannelByNum) == "undefined")
{
goToPlayChannel(ChannelNum);
}
else
{
changeChannelByNum(ChannelNum);
hiddenChanNumDiv("channel_num");
hiddenChanNumDiv("channel_line");
}
ChannelNum = "";
}
function goToPlayChannel(ChannelNum)
{
window.location.href = "ChanDirectAction.jsp?chanNum="+ChannelNum;
}
function keyBottomLine()
{
createDiv("channel_line","35px","48px");
clearTimeout(lineTimeout);
if(checkChanNumShow())
{
lineIndex++;
if(lineIndex == lineArray.length)
lineIndex=0;
}
ChannelNum = "";
document.getElementById("channel_num").innerText = ChannelNum;
document.getElementById("channel_line").innerText = lineArray[lineIndex];
showChanNumDiv("channel_line");
lineTimeout = setTimeout(function(){hiddenChanNumDiv("channel_line");},2000);
}
function showChanNumDiv(divName)
{
document.getElementById(divName).style.display = "block";
}
function hiddenChanNumDiv(divName)
{
document.getElementById(divName).style.display = "none";
}
function checkChanNumShow()
{
return document.getElementById("channel_line").style.display == "block";
}
document.onkeydown = grabEvent;
document.onkeydown = grabEvent;
function grabEvent(event)
{
//var keycode = event.which;
var keycode = event.keyCode;
switch(keycode)
{
case 8 :keyBack() ;return 0;break;
case 270:keyBack() ;return 0;break;
case 275:keyBvod() ;return 0;break;
case 276:keyTvod() ;return 0;break;
case 277:keyVod() ;return 0;break;
case 278:loadMiniInfo() ;return 0;break;
case 281:keyFavourite() ;return 0;break;
case 271:keyPos() ;return 0;break;
case 1108:keyBvod() ;return 0;break;
case 1110:keyTvod() ;return 0;break;
case 1109:keyVod() ;return 0;break;
case 1111:keyComm() ;return 0;break;
case 262 :keyTrack() ;return 0;break;
case 268 :keyInfo() ;return 0;break;
case 284 :keyHelp() ;return 0;break;
case 768 :
if(typeof(patentwindowflag) != "undefined" && patentwindowflag){
document.getElementById("videoPlay").contentWindow.keyIptvEvent();
}else{
keyIptvEvent();
}
return 0;break;
case 263 : keyPausePlay() ;return 0;break;
case 259:keyVolUp();return 0;break;
case 260:keyVolDown();return 0;break;
case 257:keyChannelUp() ;return 0;break;
case 258:keyChannelDown() ;return 0;break;
case 261:keyMute() ;return 0;break;
case 264:keyFastForward() ;return 0;break;
case 265:keyFastRewind() ;return 0;break;
case 283:keyBottomLine() ;return 0;break;
case 39170:keyPreviewTimesOver() ;return 0;break;
case 39171:keyPreviewTimesUp() ;return 0;break;
case 39172:keyStbNoChannel() ;return 0;break;
case 37 :keyLeft(); return 0;break;
case 39 :keyRight() ;return 0;break;
case 38 :keyUp() ;return 0;break;
case 40 :keyDown() ;return 0;break;
case 48 :inputNum(0) ;return 0;break;
case 49 :inputNum(1) ;return 0;break;
case 50 :inputNum(2) ;return 0;break;
case 51 :inputNum(3) ;return 0;break;
case 52 :inputNum(4) ;return 0;break;
case 53 :inputNum(5) ;return 0;break;
case 54 :inputNum(6) ;return 0;break;
case 55 :inputNum(7) ;return 0;break;
case 56 :inputNum(8) ;return 0;break;
case 57 :inputNum(9) ;return 0;break;
case 272:keyPortal() ;return 0;break;
case 33 :keyPageUp() ;return 0;break;
case 34 :keyPageDown() ;return 0;break;
case 13 :keyOk() ;return 0;break;
default:
//return 0 ;
//break ;
}
}
3.6 master
function keyUp(){
pageControl.moveUp();
}
function keyRight(){
pageControl.moveRight();
}
function keyDown(){
pageControl.moveDown();
}
function keyLeft(){
pageControl.moveLeft();
}
function keyOk(){
pageControl.ok();
}
function keyBack(){
if(typeof(pageControl.keyBack) != 'undefined'){
pageControl.keyBack();
return;
}
if(typeof(closemedia) != 'undefined'){
closemedia();
}
var url = getbackurl();
if(url){
window.location=url;
}
}
3.7 common.js
//获取id
function $(aaa){
var a = document.getElementById(aaa);
return a;
}
//刷新时间
function fnRefreshTime(interval){
interval=typeof interval==='undefined'?60:interval
var d=new Date()
var mins=d.getMinutes()
time.innerHTML=d.getHours()+':'+(mins<10?('0'+mins):mins)
setTimeout(function(){
fnRefreshTime()
},interval*1000)
var months=d.getMonth();
day.innerHTML=(months<10?(''+months+1):months+1) + "/" + d.getDate();
}
//一个元素动画
function fnEleAnimat(ele,styleName,current,des,mul,callback,callbackParas){
isAnimat=true
animat()
function animat(){
current+=mul
if(moveEnd()){
current=des
fnUpdateEleStyle(ele,styleName,current+'px')
callback&&callback(callbackParas)
isAnimat=false
return
}
fnUpdateEleStyle(ele,styleName,current+'px')
setTimeout(animat,20)
}
function moveEnd(){
return mul>0?current>=des:current<=des
}
}
//两个元素同时动画
function fnElesAnimat(ele1,styleName1,current1,des1,mul1,ele2,styleName2,current2,des2,mul2,callback,callbackParas){
isAnimat=true
animat()
function animat(){
var ele1MoveEnd=false
var ele2MoveEnd=false
current1+=mul1
current2+=mul2
if(!ele1MoveEnd){
if(moveEnd1()){
current1=des1
fnUpdateEleStyle(ele1,styleName1,current1+'px')
ele1MoveEnd=true
}else{
fnUpdateEleStyle(ele1,styleName1,current1+'px')
}
}
if(!ele2MoveEnd){
if(moveEnd2()){
current2=des2
fnUpdateEleStyle(ele2,styleName2,current2+'px')
ele2MoveEnd=true
}else{
fnUpdateEleStyle(ele2,styleName2,current2+'px')
}
}
//两个动画都结束
if(ele1MoveEnd&&ele2MoveEnd){
callback&&callback(callbackParas)
isAnimat=false
return
}
setTimeout(animat,20)
}
function moveEnd1(){
return mul1>0?current1>=des1:current1<=des1
}
function moveEnd2(){
return mul2>0?current2>=des2:current2<=des2
}
}
//更改元素样式
function fnUpdateEleStyle(ele,styleName,val){
ele.style[styleName]=val
}
//移除元素样式
function fnRemoveEleClass(ele,className){
var classNames=ele.className
if(classNames.indexOf(className)==0){
ele.className=classNames.replace(className,'')
}
if(classNames.indexOf(className)>0){
ele.className=classNames.replace(' '+className,'')
}
}
//添加元素样式
function fnAddEleClass(ele,className){
if(ele.className.indexOf(className)>=0){
return
}
ele.className+=' '+className
}
//修改元素样式
function fnModifyEleClass(ele,oldClassName,newClassName){
if(ele.className.indexOf(oldClassName)>=0){
fnRemoveEleClass(ele,oldClassName)
}
fnAddEleClass(ele,newClassName)
}
//移除当前节目效果
function fnRemoveCurrentStyle(){
fnAddEleClass(program.current.ele.getElementsByClassName('program-sel')[0],'dn')
}
//添加当前节目效果
function fnAddCurrentStyle(){
fnRemoveEleClass(program.current.ele.getElementsByClassName('program-sel')[0],'dn')
}
function fnGetQueryStringByName(name) {
var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
if (result == null || result.length < 1) {
return "";
}
return result[1];
}
//nav添加移入样式
function changeUrlIn(ele){
var src = ele.getElementsByTagName('img')[0].getAttribute('src')
var imgName = src.slice(src.indexOf('/')+1,src.indexOf('.'))+'H';
ele.getElementsByTagName('img')[0].setAttribute('src','images/'+imgName+'.png')
}
//nav添加移出样式
function changeUrlOut(ele){
var src = ele.getElementsByTagName('img')[0].getAttribute('src')
var imgName = src.slice(src.indexOf('/')+1,src.indexOf('.'));
imgName=imgName.substring(0,imgName.length-1)
ele.getElementsByTagName('img')[0].setAttribute('src','images/'+imgName+'.png')
}
//动态插入电影海报焦点列表
function pushMMp(){
moiveMoveParas = [];
for(var i = 0; i < moveList.length; i++){
//不是最后一行 并且 不是最后一个元素 并且 第二行对应的位置还有元素
if(Math.floor(i/5) < oUlNum-1 && i!=moveList.length-1 && i+5<moveList.length){
moiveMoveParas.push({up:Math.floor(i/5)==0?-1:i-5,right:i+1,down:i+5,left:i-1});
}
//不是最后一行 并且 不是最后一个元素 并且 第二行没有对应的位置还有元素
if(Math.floor(i/5)< oUlNum-1 && i!=moveList.length-1 && i+5>=moveList.length){
moiveMoveParas.push({up:Math.floor(i/5)==0?-1:i-5,right:i+1,down:moveList.length-1,left:i-1});
}
//不是最后一行 并且 是最后一个元素 并且 第二行没有对应的位置还有元素
if(Math.floor(i/5) < oUlNum-1 && i==moveList.length-1 && i+5>=moveList.length){
moiveMoveParas.push({up:Math.floor(i/5)==0?-1:i-5,right:-1,down:-1,left:i-1});
}
//不是最后一行 并且 是最后一个元素 并且 第二行对应的位置还有元素
if(Math.floor(i/5) < oUlNum-1 && i==moveList.length-1 && i+5<moveList.length){
moiveMoveParas.push({up:Math.floor(i/5)==0?-1:i-5,right:-1,down:i+5,left:i-1});
}
//在最后一行 并且 不是最后一个元素
if(Math.floor(i/5)==oUlNum-1 && i!=moveList.length-1 ){
moiveMoveParas.push({up:i-5,right:i+1,down:-1,left:i-1});
}
//在最后一行 并且 是最后一个元素
if(Math.floor(i/5)==oUlNum-1 && i==moveList.length-1){
moiveMoveParas.push({up:i-5,right:-1,down:-1,left:i-1});
}
}
for(var i = 0; i < moveList.length; i++){
if(i%5==0){
moiveMoveParas[i].left = 100;
}
if(i%5==4){
moiveMoveParas[i].right = -1;
}
}
}
function getCookie(c_name)
{
if (document.cookie.length>0){
var c_start=document.cookie.indexOf(c_name + "=")
if(c_start!=-1)
{
c_start=c_start + c_name.length+1
var c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return document.cookie.substring(c_start,c_end)
}
}
return ""
}
function setCookieByescape(name,value)
{
document.cookie = name + "="+ escape (value);
}
function getCookieByunescape(c_name)
{
if (document.cookie.length>0){
var c_start=document.cookie.indexOf(c_name + "=")
if(c_start!=-1)
{
c_start=c_start + c_name.length+1
var c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end));
}
}
return ""
}
//获取字符串长度 按字符来计算,汉字为2个字符长度
function getStrLength(str){
str = str.replace(new RegExp(/( )/g), " ");
var realLength = 0;
var len = str.length;
var charCode = -1;
for (var i = 0; i < len; i++) {
charCode = str.charCodeAt(i);
if (charCode >= 0 && charCode <= 128) realLength += 1;
else realLength += 2;
}
return realLength;
}
//获取字符串该长度的字符位置 按字符来计算,汉字为2个字符长度
function getStrIndex(str, length){
str = str.replace(new RegExp(/( )/g), " ");
var realLength = 0;
var len = str.length;
var charCode = -1;
var i = 0;
for (i = 0; i < len; i++) {
charCode = str.charCodeAt(i);
if (charCode >= 0 && charCode <= 128) realLength += 1;
else realLength += 2;
if(realLength > length){
break;
}
}
return i - 1;
}
function getuserid(){
var userid = '';
if(typeof(Authentication) != "undefined"){
if ('CTCSetConfig' in Authentication) {
userid = Authentication.CTCGetConfig("UserID");//USERID
} else {
userid = Authentication.CTCGetConfig("UserID");
}
//alert("userid:" + userid);
}else{
//alert("undefined");
}
return userid;
}
function playByAPK(playurl,startTime, name, code,tryflag,orderInfo,episodes,callbackurl, videotype, cp){
var strjson = "{\"intentType\":0,\"appName\":\"com.anhui.tv\", \"className\":\"com.anhui.tv.activity.AnHuiPlayDemandActivity\"," +
"\"extra\":[{\"name\":\"PlayUrl\", \"value\":\""+ playurl + "\"}," +
"{\"name\":\"StartTime\", \"value\":\""+ startTime + "\"}," +
"{\"name\":\"Type\", \"value\":\"0\"}," +
"{\"name\":\"Title\", \"value\":\"" + name + "\"},"+
"{\"name\":\"Vid\", \"value\":\"" + code + "\"},"+
"{\"name\":\"AutoPlay\", \"value\":\"1\"},"+
"{\"name\":\"Bwatermark\", \"value\":\"0\"},"+
"{\"name\":\"Cp\", \"value\":\"" + cp + "\"},"+
"{\"name\":\"Battempt\", \"value\":\"" + tryflag + "\"},"+
"{\"name\":\"AttemptTime\", \"value\":\"7\"},"+
"{\"name\":\"AttemptUrl\", \"value\":\"" + orderInfo + "\"},"+
"{\"name\":\"License\", \"value\":\"ahdx\"},"+
"{\"name\":\"Episodes\", \"value\":\"" + episodes + "\"},"+
"{\"name\":\"WebReturnUrl\", \"value\":\""+ callbackurl + "\"},"+
"{\"name\":\"VideoType\", \"value\":\"" + videotype + "\"}]}";
//alert("strjson:" + strjson);
STBAppManager.startAppByIntent(strjson);
//alert("back");
}
//catgory_id : 分类
//type : 类型 : 1 分类列表 2 节目列表 3 节目详情 4 频道列表
function getJSPath(catgory_id, type){
var path = "";
if("undefined" != typeof config_basepath){
path = config_basepath;
if(type == 1){
path = path + config_jsCategoryPath;
}else if(type == 2){
path = path + config_jsContentPath;
}else if(type == 3){
path = path + config_jsDetailPath;
}else if(type == 4){
path = path + config_jsChannelPath;
}
if(catgory_id == ''){
return path;
}
var length = catgory_id.length;
var location = 1;
do{
path = path + catgory_id.substring(0, location) + "/";
location = location + 3;
}while(location <= length);
}
return path;
}
function loadJS(url){
var script = document.createElement("script");
script.type = "text/javascript";
if(url.indexOf("?time=") < 0){
url = url + '?time=' + new Date().getTime();
}
script.src = url;
document.body.appendChild(script);
}
function loadJS_Async(url, callback){
var script = document.createElement("script");
script.type = "text/javascript";
if(script.readyState){ // IE
script.onreadystatechange = function(){
if(script.readyState == "loaded" || script.readyState == "complete"){
script.onreadystatechange = null;
callback();
}
};
}else{ // FF, Chrome, Opera, ...
script.onload = function(){
callback();
};
}
if(url.indexOf("?time=") < 0){
url = url + '?time=' + new Date().getTime();
}
script.src = url;
document.body.appendChild(script);
}
function randomArray(count, jsonarr, code){
var length = jsonarr.length;
var randomarr = [];
var arrindex = [];
var flag = true;
var random = 0;
if(length == 1){
return randomarr;
}
var i = 0;
if(length <= (count + 1)){
var j = 0;
for(i = 0; i < length; i++){
if(jsonarr[random].code == code){
continue;
}
randomarr[j] = jsonarr[i];
j++;
}
return randomarr;
}
for(i = 0; i < count; i++){
if(i == 0){
random = Math.floor(Math.random() * length);
if(jsonarr[random].code == code){
i = -1;
continue;
}
arrindex[i] = random;
randomarr[i] = jsonarr[random];
}else{
flag = true;
while(flag){
flag = false;
random = Math.floor(Math.random() * length);
for(var index in arrindex){
if(random == arrindex[index]){
flag = true;
break;
}
if(jsonarr[random].code == code){
flag = true;
break;
}
}
}
arrindex[i] = random;
randomarr[i] = jsonarr[random];
}
}
return randomarr;
}
function sleep(numberMillis) {
var now = new Date();
var Time = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
3.8 back.js
//获取返回的地址
function getbackurl(){
var strCookie = document.cookie;
var arrCookie=strCookie.split(";"); //将每个cookie键值对分割出来
var cookieValue;
var backurl = "";
//循环所有键值对,找得backurl
for(var i=0;i<arrCookie.length;i++){
cookieValue = arrCookie[i];
if(cookieValue.indexOf("ddfile") >= 0){
var strurls = cookieValue.split("=");
if(strurls[1] != ""){
var arrurl = strurls[1].split("|");
backurl = arrurl[arrurl.length - 1];
backurl = unescape(backurl);//取到的返回地址值
var index = strurls[1].lastIndexOf('|');
//重新设置返回地址的值
if(index == -1){
document.cookie = "ddfile="+"; path=/";
}else{
document.cookie = "ddfile=" + strurls[1].substring(0, index)+"; path=/";
}
break;
}
}
}
return backurl;
}
//设置返回路径到cookie
function setpageurl(pageurl){
pageurl = escape(pageurl);//将url编码,防止url中含有特殊字符
// alert("pageurl--"+pageurl);
var strCookie = document.cookie;
var index = strCookie.indexOf("ddfile");
//判断backurl在cookie是否存在
if(index >= 0){
// alert("setpage if index="+index);
var arrCookie=strCookie.split(";");//将每个cookie键值对取出来
var cookieValue;
//循环找到pageurl并修改值
for(var i=0;i<arrCookie.length;i++){
cookieValue = arrCookie[i];
var strurls = cookieValue.split("=");
var temp = strurls[0];
if(temp.indexOf('ddfile') >= 0){//判断是否是pageurl
var backurls = strurls[1];
backurls = backurls + "|" + pageurl;//追加返回地址值
document.cookie = "ddfile=" + backurls+"; path=/";
break;
}
}
}else{
// alert("setpage else index="+index);
document.cookie = "ddfile=" + pageurl+"; path=/";
}
}
3.9 vodplay.js
var seriesListTags = document.getElementsByClassName("seriesList");
var tabnumTags = document.getElementsByClassName("tabnum");
var exitbuttonTags = document.getElementsByClassName("exitbutton");
var seriesListParas = [{ up: -1, right: -1, down: -1, left: -1 }];
var tabnumMoveParas = [{ up: -1, right: -1, down: -1, left: -1 }];
var exitbuttonMoveParas = [
{ up: -1, right: 1, down: -1, left: -1 },
{ up: -1, right: -1, down: -1, left: 0 },
];
var area = {
100: {
ele: seriesListTags,
paras: seriesListParas,
currentIndex: 0,
selStyle: "seriesSel",
},
101: {
ele: tabnumTags,
paras: tabnumMoveParas,
currentIndex: 0,
selStyle: "setSel",
},
102: {
ele: exitbuttonTags,
paras: exitbuttonMoveParas,
currentIndex: 0,
selStyle: "buttonSel",
},
current: 101,
};
function setseriesListParas() {
seriesListParas = [];
var seriesListPara = {};
var up = -1;
var right = -1;
var down = -1;
var left = -1;
for (var i = 0; i < serienums; i++) {
seriesListPara = {};
if (i == 0) {
left = -1;
} else {
left = i - 1;
}
if (i + 1 < serienums) {
right = i + 1;
} else {
right = -1;
}
up = -1;
down = 101;
seriesListPara.left = left;
seriesListPara.right = right;
seriesListPara.up = up;
seriesListPara.down = down;
seriesListParas[i] = seriesListPara;
}
area[100].paras = seriesListParas;
seriesListTags = document.getElementsByClassName("seriesList");
area[100].ele = seriesListTags;
area[100].currentIndex = 0;
}
var current = {};
var pageControl = {};
function fnSetCurrent() {
var ca = area[area.current];
current.area = ca;
current.index = ca.currentIndex;
current.ele = ca.ele[current.index];
}
function fnGetNextEleIndex(dir) {
return current.area.paras[current.index][dir];
}
pageControl.moveLeft = function () {
if (!series_showflag && !exitshowflag) {
clearTimeout(jumptime_flag);
clearTimeout(timeflag);
showprogressbar();
mpjump(0 - jumptime);
timeflag = setTimeout("hiddenprogressbar()", 2000);
jumptime = jumptime + 1;
jumptime_flag = setTimeout("resumejumptime()", 300);
return false;
}
if (series_showflag) {
clearTimeout(series_timeflag);
showseriesDiv();
series_timeflag = setTimeout("hiddenseriesDiv()", 3000);
}
var nextEle = fnGetNextEleIndex("left");
if (nextEle == -1) {
return false;
}
if (nextEle >= 100) {
area.current = nextEle;
nextEle = current.index;
}
fnRemoveEleClass(current.ele, current.area.selStyle);
current.area.currentIndex = nextEle;
fnSetCurrent();
fnAddEleClass(current.ele, current.area.selStyle);
if (area.current == 101) {
setseries(current.index);
}
};
pageControl.moveRight = function () {
if (!series_showflag && !exitshowflag) {
clearTimeout(jumptime_flag);
clearTimeout(timeflag);
showprogressbar();
mpjump(jumptime);
timeflag = setTimeout("hiddenprogressbar()", 2000);
jumptime = jumptime + 1;
jumptime_flag = setTimeout("resumejumptime()", 300);
return false;
}
if (series_showflag) {
clearTimeout(series_timeflag);
showseriesDiv();
series_timeflag = setTimeout("hiddenseriesDiv()", 3000);
}
var nextEle = fnGetNextEleIndex("right");
if (nextEle == -1) {
return false;
}
if (nextEle >= 100) {
area.current = nextEle;
nextEle = current.index;
}
fnRemoveEleClass(current.ele, current.area.selStyle);
current.area.currentIndex = nextEle;
fnSetCurrent();
fnAddEleClass(current.ele, current.area.selStyle);
if (area.current == 101) {
setseries(current.index);
}
};
var series_showflag = false;
pageControl.moveUp = function () {
if (!series_showflag && !exitshowflag) {
if (seriesflag == "1") {
series_showflag = true;
showseriesDiv();
fnSetCurrent();
fnAddEleClass(current.ele, current.area.selStyle);
clearTimeout(series_timeflag);
series_timeflag = setTimeout("hiddenseriesDiv()", 3000);
return false;
} else {
return false;
}
}
var nextEle = fnGetNextEleIndex("up");
if (nextEle == -1) {
return false;
}
if (nextEle >= 100) {
area.current = nextEle;
nextEle = current.index;
}
fnRemoveEleClass(current.ele, current.area.selStyle);
current.area.currentIndex = nextEle;
fnSetCurrent();
fnAddEleClass(current.ele, current.area.selStyle);
};
pageControl.moveDown = function () {
if (!series_showflag) {
return false;
} else {
clearTimeout(series_timeflag);
showseriesDiv();
series_timeflag = setTimeout("hiddenseriesDiv()", 3000);
}
var nextEle = fnGetNextEleIndex("down");
if (nextEle == -1) {
return false;
}
if (nextEle >= 100) {
area.current = nextEle;
nextEle = current.index;
}
fnRemoveEleClass(current.ele, current.area.selStyle);
current.area.currentIndex = nextEle;
fnSetCurrent();
fnAddEleClass(current.ele, current.area.selStyle);
};
var exitshowflag = false;
pageControl.keyBack = function () {
if (!exitshowflag) {
mp.pause();
exitshowflag = true;
document.getElementsByClassName("exit")[0].style.display = "block";
area.current = 102;
fnSetCurrent();
fnAddEleClass(current.ele, current.area.selStyle);
} else {
mp.resume();
exitshowflag = false;
document.getElementsByClassName("exit")[0].style.display = "none";
area[102].currentIndex = 0;
fnRemoveEleClass(current.ele, current.area.selStyle);
area.current = 101;
fnSetCurrent();
}
};
var playstatus = 1; //1:正在播放 2:暂停
pageControl.ok = function () {
if (exitshowflag) {
if (current.index == 0) {
mp.resume();
parent.smallplay();
} else {
mp.resume();
}
exitshowflag = false;
if (area[102].currentIndex == 1) {
// 确定
updateProgram();
closemedia();
window.history.go(-1);
// window.location.href = './detailPlay.html?primaryId=' + dealUrl(window.location.href).primaryId+"&value=" + dealUrl(window.location.href).value;
} else {
document.getElementsByClassName("exit")[0].style.display = "none";
}
area[102].currentIndex = 0;
fnRemoveEleClass(current.ele, current.area.selStyle);
area.current = 101;
fnSetCurrent();
return;
}
if (series_showflag && area.current == 100) {
series_timeflag = setTimeout("hiddenseriesDiv()", 3000);
var index = current.index + area[101].currentIndex * 15;
var playurl = programDetial.serieslist[index].playurl;
closemedia();
initVideo();
playVideo(playurl, playtime);
return false;
}
if (playstatus == 1) {
mpjump(0);
playstatus = 2;
mp.pause();
$("playstatus").style.background =
"url(../../images/Eimg/player_icon_pause.png) no-repeat";
$("pauseDiv").style.visibility = "visible";
showprogressbar();
} else {
playstatus = 1;
mp.resume();
$("pauseDiv").style.visibility = "hidden";
$("playstatus").style.background =
"url(../../images/Eimg/player_icon_playing.png) no-repeat";
timeflag = setTimeout("hiddenprogressbar()", 2000);
}
};
var timeflag;
var volume_timeflag;
function keyVolUp() {
clearTimeout(volume_timeflag);
showvolume();
var volume = mp.getVolume();
volume = volume + 5;
if (volume > 100) {
volume = 100;
}
mp.setVolume(volume);
$("volumecolorbar").style.height = volume * 4 + "px";
$("volumepercent").innerHTML = volume + "%";
volume_timeflag = setTimeout("hiddenvolume()", 2000);
}
function keyVolDown() {
clearTimeout(volume_timeflag);
showvolume();
var volume = mp.getVolume();
volume = volume - 5;
if (volume < 0) {
volume = 0;
}
mp.setVolume(volume);
$("volumecolorbar").style.height = volume * 4 + "px";
$("volumepercent").innerHTML = volume + "%";
volume_timeflag = setTimeout("hiddenvolume()", 2000);
}
var programDetial = {};
var seriesflag = "";
var instanceId = -1;
window.onload = function () {
/* var category_id = fnGetQueryStringByName('category_id');
var jsurl = getJSPath(category_id, 3);
jsurl = jsurl + 'D' + fnGetQueryStringByName('code') + '.js';
loadJS(jsurl);*/
var areaFrom = fnGetQueryStringByName("area");
var indexFrom = fnGetQueryStringByName("index");
if (areaFrom != "" && indexFrom != "") {
area.current = areaFrom;
area[area.current].currentIndex = indexFrom;
}
/* //找到获取焦点元素
fnSetCurrent();
//添加样式
fnAddEleClass(current.ele,current.area.selStyle);*/
};
// var tabnums = 0;
// var serienums = 0;
// function ContentDetailCallback(json){
// programDetial = json;
// seriesflag = programDetial.seriesflag;
// var strhtml = '';
// $("playprogramname").innerHTML ='正在播放:' + programDetial.name;
// if(seriesflag == '1'){
// $("seriesnum").innerHTML = "(第" + programDetial.serieslist[seriesindex].sequence + "集)";
// $("playprogramname").innerHTML = $("playprogramname").innerHTML + $("seriesnum").innerHTML;
// var serieslist = programDetial.serieslist;
// var length = serieslist.length;
// tabnums = Math.ceil(length/15);
// strhtml = '';
// for(var i = 0; i < tabnums; i++){
// var start = i * 15 + 1;
// var end = 0;
// if((i + 1) < tabnums){
// end = (i + 1) * 15;
// }else{
// end = length;
// }
// strhtml = strhtml + '<span class="tabnum">' + start + "-" + end + '</span>';
// }
// $("tab").innerHTML = strhtml;
// settabnumMoveParas();
// setseries(0);
// }
// //bindVideo();
// }
// function setseries(tabindex){
// var serieslist = programDetial.serieslist;
// var start = tabindex * 15;
// var end = 0;
// if((tabindex + 1) < tabnums){
// end = (tabindex + 1) * 15;
// }else{
// end = serieslist.length;
// }
// var strhtml = '';
// for(var i = start; i < end; i++){
// strhtml = strhtml + '<div class="seriesList"><span>' + serieslist[i].sequence + '</span></div>'
// }
// serienums = end - start;
// $("seriesList").innerHTML = strhtml;
// setseriesListParas();
// }
// function setseriesListParas(){
// seriesListParas = [];
// var seriesListPara = {};
// var up = -1;
// var right = -1;
// var down = -1;
// var left = -1;
// for(var i = 0; i < serienums; i++){
// seriesListPara = {};
// if(i == 0){
// left = -1;
// }else{
// left = i - 1;
// }
// if((i + 1) < serienums){
// right = i + 1;
// }else{
// right = -1;
// }
// up = -1;
// down = 101;
// seriesListPara.left = left;
// seriesListPara.right = right;
// seriesListPara.up = up;
// seriesListPara.down = down;
// seriesListParas[i] = seriesListPara;
// }
// area[100].paras = seriesListParas;
// seriesListTags= document.getElementsByClassName('seriesList');
// area[100].ele = seriesListTags;
// area[100].currentIndex = 0;
// }
// function settabnumMoveParas(){
// tabnumMoveParas = [];
// var tabnumMovePara = {};
// var up = -1;
// var right = -1;
// var down = -1;
// var left = -1;
// for(var i = 0; i < tabnums; i++){
// tabnumMovePara = {};
// if(i == 0){
// left = -1;
// }else{
// left = i - 1;
// }
// if((i + 1) < tabnums){
// right = i + 1;
// }else{
// right = -1;
// }
// up = 100;
// down = -1;
// tabnumMovePara.left = left;
// tabnumMovePara.right = right;
// tabnumMovePara.up = up;
// tabnumMovePara.down = down;
// tabnumMoveParas[i] = tabnumMovePara;
// }
// area[101].paras = tabnumMoveParas;
// tabnumTags= document.getElementsByClassName('tabnum');
// area[101].ele = tabnumTags;
// }
function hiddenvolume() {
$("volumeDiv").style.visibility = "hidden";
}
function showvolume() {
$("volumeDiv").style.visibility = "visible";
}
function showprogressbar() {
$("progressdiv").style.visibility = "visible";
}
function hiddenprogressbar() {
$("progressdiv").style.visibility = "hidden";
}
var jumptime = 20;
var jumptime_flag;
function resumejumptime() {
jumptime = 20;
}
function showquestion() {
$("question").style.visibility = "visible";
}
function hiddenquestion() {
$("question").style.visibility = "hidden";
}
var series_timeflag;
function showseriesDiv() {
$("seriesDiv").style.visibility = "visible";
}
function hiddenseriesDiv() {
series_showflag = false;
$("seriesDiv").style.visibility = "hidden";
}
function mpjump(jump) {
var duration = parseInt(mp.getMediaDuration(), 10);
var currenttime = parseInt(mp.getCurrentPlayTime(), 10) + jump;
//alert("duration:" + duration + "$currenttime:" + currenttime);
if (currenttime > duration) {
currenttime = duration;
} else if (currenttime < 0) {
currenttime = 0;
}
var width = (currenttime / duration) * 1000 + "px";
$("progressbar").style.width = width;
var minute;
var second;
var minute1;
var second1;
minute = Math.floor(currenttime / 60);
second = currenttime % 60;
minute1 = Math.floor(duration / 60);
second1 = duration % 60;
if (second < 10) {
second = "0" + second;
}
if (second1 < 10) {
second1 = "0" + second1;
}
$("playtime").innerHTML =
minute + ":" + second + "/" + minute1 + ":" + second1;
$("playtime").setAttribute("time", duration);
$("playingtime").innerHTML = minute + ":" + second;
$("playingtimediv").style.left = width;
mp.playByTime(-1, currenttime, 1);
}
function close() {
parent.smallplay();
closemedia();
}
希望读到这篇文章会对你有帮助~,有帮助请留下一个赞(*╹▽╹*)文章来源:https://www.toymoban.com/news/detail-405043.html
——————来自李易峰的小粉丝,凡凡同学文章来源地址https://www.toymoban.com/news/detail-405043.html
到了这里,关于机顶盒(Iptv)EPG页面实现视频播放的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!