- initEvent:function(){
- var self = this;
- G_PLAYER_INSTANCE.attachEvent(G_PLAYER_INSTANCE,'onGetFormats',function(_o,_e,that,from){
- self.getFormats();
- });
- G_PLAYER_INSTANCE.attachEvent(G_PLAYER_INSTANCE,'onSetFormats',function(_o,_e,that,from,format,isdefault){
- self.setFormats(that,from,format,isdefault);
- });
- G_PLAYER_INSTANCE.attachEvent(G_PLAYER_INSTANCE,'onErrorStat',function(_o,_e,code){
- self.stat({f:'playerror',e:code,from:from});
- if(from=='xlpan_web'&& self.kkvaUsed){
- try{
- G_PLAYER_INSTANCE.close();
- G_PLAYER_INSTANCE.closeNetStream();
- G_PLAYER_INSTANCE.setNoticeMsg('看看加速播放服务已经退出,您将无法继续观看视频,请刷新页面重试',5000);
- }catch(e){}
- //var timer= setTimeout(function(){try{G_PLAYER_INSTANCE.stop();clearTimeout(timer);}catch(e){};},4000);
- self.kkvaUsed =false;
-
- }
- });
- G_PLAYER_INSTANCE.attachEvent(G_PLAYER_INSTANCE,'onErrorExit',function(_o,_e,code,msg){
- self.stat({f:'playerror',e:code,from:from});
- });
- G_PLAYER_INSTANCE.attachEvent(G_PLAYER_INSTANCE,'onplaying',function(){
- self.stats_buff();
- if( from=='xlpan_web' && self.kkvaValid ){
- self.kkvaUsed = true;
- try{G_PLAYER_INSTANCE.setNoticeMsg('<a href="javascript:var dpopen=function(){var dapctrl=null;try{dapctrl=new ActiveXObject(\'DapCtrl.DapCtrl\');}catch(e){};var link=\'http://dl.xunlei.com/xmp.html\';if(dapctrl){dapctrl.Put(\'iADShowMode\',1);dapctrl.Put(\'sOpenAdUrl\',link);dapctrl=null;}else{window.open(link)}};dpopen();" target="_self">看看加速服务中...</a>',15);}catch(e){}
- self.kkvaValid = false;
- }
-
- });
- },
- stat:function(param){
- var param = param || {};
- var p = [];
- param.p = 'XCVP';
- if(typeof param.u == 'undefined')
- param.u = getCookie('userid')||0;
-
- if(typeof param.v == 'undefined')
- param.v = getCookie('isvip')||0;
- if(typeof param.from == 'undefined')
- param.from = 'XCVP';
-
- for(var i in param) {
- p.push(i + "=" + encodeURIComponent(param[i]));
- }
- try{
- setTimeout(function(){
- var img = new Image(0,0);
- img.src = 'http://i.vod.xunlei.com/stat/s.gif?'+p.join('&');
- },5);
- }catch(e){}
- },
- stats_buff_flag:false,
- stats_buff:function(){
- if(this.stats_buff_flag) return;
- this.stat({f:'firstbuffer',from:from,time:(new Date().getTime() - this.initTime)});
- this.stats_buff_flag = true;
- },
- query:function(){
- var that = this,timerFlag=true;
- var timer = setTimeout(function(){
- if(timerFlag)
- that.error("服务器异常,稍后重试!");
- },10*1000);
- var vip = getCookie('isvip')||0;
- var userid = getCookie('userid')||2;
-
- if(userid==2)
- setCookie("trial_play","trial_play");
- var req = "http://i.vod.xunlei.com/req_get_method_vod?url="+encodeURIComponent(url)+'&video_name='+encodeURIComponent(filename)+'&platform='+(isIpad?"1":"0")+"&userid="+userid+"&vip="+vip;
- if(gcid)
- req = req +'&gcid='+gcid;
- if(cid)
- req = req +'&cid='+cid;
- if(filesize)
- req = req+'&filesize='+filesize;
- req = req+'&cache='+new Date()+'&from='+from;
- getJSONP(req,'XL_CLOUD_FX_INSTANCEqueryBack',function(r){
- clearTimeout(timer);
- timerFlag=false;
- that.queryBack(r);
- });
-
- },
- queryBack:function(req){
- var req = req.resp;
- var that = this;
- if(req.status!=0){
- this.error("文件在云端尚未准备就绪,请休息一会儿再回来!");
-
- }
- else{
- var that = this;
- _INSTANCE.attachEvent(_INSTANCE,'onload',function(){
- that.initEvent();
- var info = req.vodinfo_list;
- that.vod_info = info;
- that.data = req;
- that.startPlay(info[0].vod_url,'225536');
-
- that.getCaption(req.src_info.gcid,req.src_info.cid);
- createPanel();
- });
- var id = box_obj.getAttribute('id');
- _INSTANCE.printObject(id,false,'100%','100%');
- this.initTime = new Date().getTime();
- try{
- window[success].call();
- }
- catch(e){}
- }
- that.stat({f:'svrresp',ret:req.ret,pt:req.status,from:from});
- },
- startPlay:function(url,format,start,change){
- start=start||0;
- url = url+'&n=1';
- this.lastFormat = format;
- if(isIpad){
- G_PLAYER_INSTANCE.setUrl(url,start);
- this.getFormats();
- return true;
- }
- else{
- var param = {};
- param.totalByte = 1;
- param.totalTime = parseInt(this.data.duration/1000000);
- var _url = url;
- param.totalByte = parseInt(this.$PU('s',_url));
- param.sliceType = 0;
- if(start && start>0) {
- param.start = start;
- }
- G_PLAYER_INSTANCE.stop();
- G_PLAYER_INSTANCE.enableSharePanel(enable_panel);
- G_PLAYER_INSTANCE.flashopen(_url,true,false,autoplay,param,0);
- this.enableKKVA();
- }
-
-
- },
复制代码 |