1、继续教育在线学习,head部分引用了http://player.polyv.net/script/player.js,每隔10秒向服务器get数据,参数都在url中,
2、在body部分,有个script标签,内有多个function,其中一个为savePosition,也是每隔10秒向服务器post数据
3、get数据的响应值为1;
4、post响应为success;
思路一:先测试修改post数据,试试能不能达到实现加速的效果。
思路二:在思路一的基础上,同步修改get的url,看看能不能达到加速学习的效果。
难点一:在script标签多个function中,指定修改savePosition的sec1和sec2(player.j2s_stayInVideoTime()为保利威视播放器函数接口,本次视频播放时间)
难点二:player.js,如何实现定时发送的? 未发现定时器? 如何实现劫持修改?
player.js的部分代码如下:
key: "sendData",
value: function() {
var t = this.video,
e = this.duration,
i = Math.min(Math.ceil(t.currentTime), e) || 0,
n = Math.floor(this.pd),
r = c.getTs(),
a = n - this.prePd;
this.prePd = n;
var o = (r - this.sdts) / 1e3;
(o = Math.max(this.interval, Math.min(o, 60))) < a && (o = a);
var s = this.sd += o;
if (this.updateSdts(r), 0 !== n) {
var l = {
pid: this.pid,
vid: this.vid,
uid: c.getUid(this.vid),
flow: 0,
ts: c.getTs(),
href: this.href,
duration: e,
cts: i,
sign: c.getSign("rtas.net", this.pid, this.vid, 0, n, i),
sd: Math.floor(s),
pd: n,
pn: "HTML5",
pv: this.pv
};
this.appId && (l.appId = this.appId), m()(l, this.data), 1 == ++this.sendCount && (this.viewerAvatar && (l.viewerAvatar = this.viewerAvatar), l.ute = "bop"), this.data.log && console.log(l), this.allowSend && M({
url: this.URL || Xt,
type: "get",
data: l
})
}
}
script标签内代码如下:
<script type="text/javascript">
var player;
var lateInterval;
var leftTime;
var interTime = 10000;
var intervalsavePosition;
var allowFlag = "";
var sendTxt = "";
//共通方法
//new
function isIE(ver){
var b = document.createElement('b');
b.innerHTML = '<!--[if IE ' + ver + ']><i></i><![endif]-->';
return b.getElementsByTagName('i').length === 1;
}
//判断浏览器方法
//new
function isXpOrIe8(){
var sUserAgent = navigator.userAgent;
var isWinXP=false;
isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows Xp") > -1;
var isWinIE = isIE(6) ||isIE(7) ||isIE(8);
return isWinXP && isWinIE;
}
//创建播放器方法 如果isXpOrIe8()方法返回true , 则flashvarsParam参数中要增加一个is_xp_ie8:'1' 的参数
function createPolyv(playPosition,banSeekByLimitTime){
var flashvarsParam = {'autoplay':'true','watchStartTime':playPosition,'ban_seek_by_limit_time':banSeekByLimitTime,'ban_history_time':'on'};
if(isXpOrIe8()){
flashvarsParam = {'autoplay':'true','watchStartTime':playPosition,'ban_seek_by_limit_time':banSeekByLimitTime,'ban_history_time':'on',is_xp_ie8:'1'};
}
player = polyvPlayer({
wrap: '#polyvplayer02bfeb00e2ba940698c54cdf517aa9b6_0',
'vid': '5c0ad4c56c8428644f270c51ae2d76ae_5',
'width': '100%',
'height': '640',
'autoplay':true,
'speed':false,
'ban_seek_by_limit_time':banSeekByLimitTime,
'ban_history_time':'on',
'watchStartTime':playPosition
});
}
createPolyv('0','on');
function s2j_onVideoPlay(){
intervalsavePosition = setInterval(savePosition,interTime);
}
function s2j_onVideoPause(){
clearInterval(intervalsavePosition);
}
function s2j_onPlayOver(){
clearInterval(intervalsavePosition);
//if(isPlayEnd == "1") return false;
isPlayEnd = "1";
var path ="http://dlkj.edufe.cn:80/savePlayEndInteracted.action?logNo=15b22ebc-0da9-4e78-9d6a-a84980f77fe7";
$.ajax({
url: path,
type:"post",
dataType: "json",
success: function (data) {
}
});
}
function savePosition(){
if(isPlayEnd == "1") return false;
var path = "http://dlkj.edufe.cn:80/savePlayPositionInteracted.action?logNo=15b22ebc-0da9-4e78-9d6a-a84980f77fe7";
var sec1=player.j2s_stayInVideoTime();
var sec2=player.j2s_getCurrentTime();
var param = "&totalSeconds="+sec1 + "&playPosition=" + sec2;
$.ajax({
url: path+param,
type:"post",
dataType: "json",
success: function (data) {
}
})
}
function getPlayer(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
var reObj=window[movieName];
if(typeof(reObj)=="undefined"){
return document[movieName];
}
try{
if(reObj.length>0){
return reObj[0];
}else{
return reObj;
}
}catch(e){}
return ;
}else {
return document[movieName];
}
}
</script>