$(document).ready(function(){function ispc(){var useragentinfo=navigator.useragent;var agents=["android","iphone","symbianos","windows phone","ipad","ipod"];var flag=true;for(var v=0;v0){flag=false;break;}} return flag;} function _charecter(){var character=string.fromcharcode(math.floor(math.random()*26)+"a".charcodeat(0));return character;} function addzero(num){if(num<10){return("0"+num);}else{return num;}} var eventtester=function(eventname,m,fun){if(window.addeventlistener){m.addeventlistener(eventname,function(){if(fun){fun(this);}},false);}else{m.attachevent('on'+eventname,function(){if(fun){fun(this);}});}} $(".m-video").on("click",function(){if($(".video-box").length>0){return;} document.ondragstart=function(){return false;};window.onresize=function(){iteme=settimeout(function(){if(!checkfull()){$("body").removeclass("noscroll");$(".video-box").removeclass("quanping");$(".video-fullscreen").find("i").removeclass("i-suoxiao").addclass("i-quanping");}else{$("body").addclass("noscroll");$(".video-box").addclass("quanping");$(".video-fullscreen").find("i").removeclass("i-quanping").addclass("i-suoxiao");}},0)} function checkfull(){var explorer=window.navigator.useragent.tolowercase();console.log(window.screen.width,window.outerwidth,window.screen.height,window.outerheight) if(explorer.indexof('chrome')>0){if((window.screen.width-window.outerwidth<=17)&&(window.screen.height-window.outerheight<=17)){return true;}else{return false;}}else{if(window.outerwidth==screen.width){return true;}else{return false;}}} function quanpin(elem){if(ispc()){var elem=document.documentelement;}else{if(elem.paused&&elem.networkstate<=elem.have_metadata){elem.play();settimeout(function(){elem.pause();elem.webkitenterfullscreen();return;},0);}else{elem.webkitenterfullscreen();return;}} if(elem.requestfullscreen){elem.requestfullscreen();}else if(elem.mozrequestfullscreen){elem.mozrequestfullscreen();}else if(elem.webkitrequestfullscreen){elem.webkitrequestfullscreen();}else if(elem.msrequestfullscreen){console.log(11);elem.msrequestfullscreen();}} function exitquanping(){if(document.exitfullscreen){document.exitfullscreen();}else if(document.mozcancelfullscreen){document.mozcancelfullscreen();}else if(document.webkitcancelfullscreen){document.webkitcancelfullscreen();}else if(document.msexitfullscreen){document.msexitfullscreen();}} var menuarr;var menustr="";if($(this).attr("data-menu")){menuarr=$(this).attr("data-menu").split(" ");$(menuarr).each(function(k){menustr+="
  • "+this+"
  • ";})} var datasrc=$(this).attr("data-src"),src='';var dangqian="";if(src.indexof("mp4")<0&&$(this).attr("data-menu")){dangqian=menuarr[0];src=datasrc+dangqian+".mp4";}else{src=datasrc;} if(!src){alert("未添加视频链接");} console.log(src);var menu=["
    ","","
    ","
      ",menustr,"
    ","
    ","
    "];if(!$(this).attr("data-menu")){menu=[]} var vclass=$(this).attr("data-heibian")?"heibian":"";var videoid="my"+_charecter()+_charecter();var iteme=null;var str=["
    ","
    ","
    ","
    ","
    ","
    ","
    ","","
    ","
    ","
    ","
    ","
    ","
    ","","
    ","
    ","","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","","","00:00","  /  ","00:00","","
    ","","
    ",menu.join(""),"
    ","","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    ","
    "] $("body").append(str.join(""));var meido=document.getelementbyid(videoid);meido.volume=.5;var videobox=$("#"+videoid+"box");eventtester("waiting",meido,function(){console.log(" 等待数据,并非错误");$(".video-loading").removeclass("yihuanchun");});eventtester("playing",meido,function(){console.log("播放了");videobox.addclass("video-playing").removeclass("video-pause");$(".video-loading").addclass("yihuanchun");});eventtester("stalled",meido,function(){console.log("/网速失速");});eventtester("ended",meido,function(){});eventtester("canplay",meido,function(){$(".video-container",videobox).addclass("video-ready");meido.canplay=true;meido.play();$(".video-bofang").find("i").removeclass("i-bofang").addclass("i-zhanting").css("transition","none");});eventtester("loadedmetadata",meido,function(){$(".video-time-panel-total").html(addzero(parseint(meido.duration/60))+":"+addzero(parseint(meido.duration%60)));});eventtester("suspend",meido,function(){console.log("延迟下载")}) eventtester("loadstart",meido,function(){console.log("客户端开始请求数据") $(".video-loading").removeclass("yihuanchun");}) eventtester("progress",meido,function(){$(".video-container",videobox).addclass("video-ready");console.log("客户端正在请求数据")}) eventtester("timeupdate",meido,function(){if(meido.canplay){var currenttime=meido.currenttime;var buffered=meido.buffered.end(0);var duration=meido.duration;for(var i=0;i1){volumeh=1;}else{$(".video-btn-volume i").removeclass("i-voice-off").addclass("i-voice-on");} zi.css("height",volumeh*100+"%") meido.volume=volumeh;}else{return;}});$(".video-btn-volume",videobox).on("click",function(){if($(this).find("i").hasclass("i-voice-on")){meido.volume=false;volumeh=$(".video-volume-range-current",videobox).height()/$(".video-volume-range",videobox).height();console.log(volumeh);$(".video-volume-range-current",videobox).css("height",0+"%");$(".video-btn-volume i").removeclass("i-voice-on").addclass("i-voice-off");}else{meido.volume=true;$(".video-volume-range-current",videobox).css("height",volumeh*100+"%");$(".video-btn-volume i").removeclass("i-voice-off").addclass("i-voice-on");}}) $(".video-fullscreen",videobox).on("click",function(){if($(this).find("i").hasclass("i-quanping")){quanpin(meido);}else{console.log("退出全屏");exitquanping();}}) $(".video-menu-item").on("click",function(){if($(this).hasclass("video-active")){return;} $(this).addclass("video-active").siblings().removeclass("video-active");$(".video-definition-button span").html($(this).html());var duration=meido.currenttime;meido.canplay=false;meido.pause();meido.src=datasrc+$(this).html()+".mp4";meido.currenttime=duration;});});})