69 lines
16 KiB
JavaScript
69 lines
16 KiB
JavaScript
|
(function(){const L="?v20201212";let g=0,f=!1,b=0,k=new Date().getTime(),p=0,y={types:{},event:function(h){var t=this.types[h];if(t)for(var e=0;e<t.length;++e)t[e]()},addEventListener:function(h,t){this.types[h]||(this.types[h]=[]),this.types[h].push(t)}};class m{constructor(){this.handles={},this.videoRatio=16/9}static init(t){const e=this;if(typeof videojs=="undefined"){var s,l;const r=new Date().getTime();this.jsUrlArr=["/design/designstatic/chatroom/video/video.min.7.4.js?v=20191212","/design/designstatic/chatroom/video/videojs.zoomrotate.js?v=20191212","/design/designstatic/chatroom/video/videojs-contrib-hls.min.js?v=20191212"],m.addJsFun(t)}else t.call(e)}static addCss(t){var e=document.getElementsByTagName("head")[0],s=document.createElement("link");s.type="text/css",s.rel="stylesheet",s.href=t,e.appendChild(s)}static addCssFun(){const t=this.cssUrlArr;for(var e=t.length,s=0;s<e;s++)m.addCss(t[s])}static addJsFun(t){var e=this,s=this.jsUrlArr.length;s?m.addJs(this.jsUrlArr[0],function(){e.jsUrlArr.shift(),e.addJsFun.call(e,t)}):t.call(e)}static addJs(t,e){var s=document.getElementsByTagName("head")[0],l=document.createElement("script");l.type="text/javascript",l.src=t,typeof e=="function"&&(l.onload=l.onreadystatechange=function(){(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")&&(e(),l.onload=l.onreadystatechange=null)}),s.appendChild(l)}getUrlParams(t){const e=new RegExp("(^|&)"+t+"=([^&]*)(&|$)");var s=window.location.search.substr(1).match(e);return s!=null?unescape(s[2]):null}getVideoSize(){const t=this;$.ajax({url:"/api/common/tool/videoWidthHeight",headers:{token:$.cookie("token")},data:{busId:t.getUrlParams("cwid")||"",busType:"doc"},type:"GET",dataType:"json",success(e={}){if(e.success){const{data:s=""}=e,l=s.split("*"),r=l[0],n=l[1],c=r/n?r/n:16/9;t.videoRatio=c,t.getVideoStyle(c)}}})}getVideoStyle(t){const e=$("#wjplayer video"),s=16/9;if(t>s){const l=(s/t*100).toFixed(0);e.css("height",`${l}%`).attr("class","pic_default")}else{const l=(t/s*100).toFixed(0);e.css("width",`${l}%`).attr("class","pic_default")}}createVideo(t,e,s,l,r,n,c,x){this.id=t,this.url=s,this.domId=e,this.autoplay=l,this.showControls=n,this.thumbUrl=c,this.isLive=r;var w="",j=1;this.seek=x;var T,i,a,o,d,v=0;const u=`<div class="wjplayer" id="wjplayer">
|
||
|
<video id="${this.id}" poster="${this.thumbUrl}" webkit-playsinline="true" playsinline="" x5-playsinline="true" x-webkit-airplay="true"></video>
|
||
|
</div>`;if($("#"+e).length===0?this.publish("video_create_error","\u672A\u627E\u5230\u5BB9\u5668\uFF0C\u64AD\u653E\u5668\u521B\u5EFA\u5931\u8D25"):($("#"+this.domId).html(u),this.publish("video_create_complate",{videoId:this.id,documentId:this.domId})),g=$("#wjplayer").width(),this.getVideoSize(),typeof s=="string"){var S=this.getVideoType(s);S==="flv"?this.createFlv():S==="m3u8"?this.createHLS():this.createSwf()}else this.flashChecker().f!=0?(this.playerUrl=s.rtmpUrl,this.createSwf()):flvjs.isSupported()?(this.playerUrl=s.flvUrl,this.createFlv()):(this.playerUrl=s.HLSUrl,this.createHLS());window.location.href.indexOf("lookcourse.html")>-1&&$(".courseWare_content_box").height($("#live_content").height())}checkStram(){}createControls(){let t=`<div class="controls">
|
||
|
<div class="tooltips">
|
||
|
<span class="selecttime">00:50</span>
|
||
|
</div>
|
||
|
<div class="speeddiv">
|
||
|
<div class="speedgrid">
|
||
|
<span class="speedtitle" style="margin-top: 3px;">2.0\u500D</span>
|
||
|
<span class="speedtitle">1.5\u500D</span>
|
||
|
<span class="speedtitle">1.25\u500D</span>
|
||
|
<span class="speedtitle selectspeed">1.0\u500D</span>
|
||
|
<span class="speedtitle">0.75\u500D</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="settingdiv">
|
||
|
<div class="setting_box">
|
||
|
<span class="pre">\u753B\u9762\u6BD4\u4F8B:</span>
|
||
|
<span class="content js-video-ratio current" data-type="default">\u9ED8\u8BA4</span>
|
||
|
<span class="content js-video-ratio" data-type="16_9">16:9</span>
|
||
|
<span class="content js-video-ratio" data-type="4_3">4:3</span>
|
||
|
|
||
|
</div>
|
||
|
<div class="setting_box box_top">
|
||
|
<span class="pre">\u753B\u9762\u65CB\u8F6C:</span>
|
||
|
<span class="content js-spin" data-type="left">\u5DE6\u8F6C</span>
|
||
|
<span class="content js-spin" data-type="right">\u53F3\u8F6C</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="seekDiv">
|
||
|
<div class="seeklabel">\u4E0A\u6B21\u89C2\u770B\u81F3</div>
|
||
|
<div id="seektime" class="seektime">00:00</div>
|
||
|
<div class="seeklabel">\u5904\uFF0C\u5DF2\u4E3A\u60A8\u81EA\u52A8\u64AD\u653E</div>
|
||
|
<div class="seeklabel1">\u4ECE\u5934\u5F00\u59CB</div>
|
||
|
</div>
|
||
|
<div class="volumeDiv">
|
||
|
<div class="volumegrid">
|
||
|
<span id="volumeTitle">100%</span>
|
||
|
<div id="all">
|
||
|
<div id="bar">
|
||
|
<div id="bar1">
|
||
|
</div>
|
||
|
<div id="box"></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="progress">
|
||
|
<div class="track"></div>
|
||
|
<div class="loading"></div>
|
||
|
<div class="progressing"></div>
|
||
|
<div class="thumb"></div>
|
||
|
</div>
|
||
|
<div class="tools">
|
||
|
<div class="left">
|
||
|
<img src="/design/designstatic/chatroom/video/img/play.png" title="\u6682\u505C" class="playbtn" />
|
||
|
<span class="time">--:--:--/--:--:--</span>
|
||
|
</div>
|
||
|
<div class="rights">
|
||
|
<span class="speed">\u500D\u901F</span>
|
||
|
<img src="/design/designstatic/chatroom/video/img/volume.png?v=222222" title="\u97F3\u91CF" class="volume" />
|
||
|
<img src="/design/designstatic/chatroom/video/img/setting.png" title="\u8BBE\u7F6E" class="setting" />
|
||
|
<img src="/design/designstatic/chatroom/video/img/full.png" title="\u5168\u5C4F" class="full" />
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>;`;$(`#${this.domId}`).append(t),this.seek>0?($("#seektime").html(this.s_to_hs(this.seek)),this.player.currentTime(this.seek),setTimeout(function(){$(".seekDiv").hide()},4e3)):$(".seekDiv").hide(),$(".seeklabel1").click(function(){e.player.currentTime(0),$(".seekDiv").hide()});const e=this;function s(){const i=e.player.currentTime(),a=e.player.duration();let o=(i/a*$("#"+e.domId).width()).toFixed(2);const d=`${e.s_to_hs(i)} / ${e.s_to_hs(a)}`;$(".time").html(d),$(".progressing").width(o);let v=$(".vjs-control-text-loaded-percentage").html();v=v.replace("%",""),$(".loading").width(Number(v)/100*$("#"+e.domId).width()),o>$("#"+e.domId).width()-5&&(o=$("#"+e.domId).width()-5),o<0&&(o=0),$(".thumb").css("left",o+"px")}function l(){$("#bar1")[0].style.height=0+"px",$("#box")[0].style.top=100+"px",$("#volumeTitle").text(0+"%"),$(".volume").attr("src","/design/designstatic/chatroom/video/img/novolume.png"),$(".volume").attr("title","\u9759\u97F3"),e.player.volume(0)}function r(){$(".volume").attr("src","/design/designstatic/chatroom/video/img/volume.png?v=22222"),$(".volume").attr("title","\u97F3\u91CF"),$("#bar1")[0].style.height=100+"px",$("#box")[0].style.top=0+"px",$("#volumeTitle").text(100+"%"),e.player.volume(1)}window.WJPlayerUpdateProgress=s,this.player.on("timeupdate",function(){e.player.muted()&&!b&&(l(),layer&&layer.msg("\u6CA1\u6709\u58F0\u97F3\uFF0C\u8BF7\u6253\u5F00\u53F3\u4E0B\u89D2\u97F3\u91CF","",3),b=1),!e.thumbStartDrag&&s()}),this.player.on("playing",function(){$(".playbtn").attr("src","/design/designstatic/chatroom/video/img/pause.png"),$(".playbtn").attr("title","\u6682\u505C")}),this.player.on("pause",function(){$(".playbtn").attr("src","/design/designstatic/chatroom/video/img/play.png"),$(".playbtn").attr("title","\u64AD\u653E")}),this.player.on("ended",function(){$(".playbtn").attr("src","/design/designstatic/chatroom/video/img/replay.png"),$(".playbtn").attr("title","\u91CD\u64AD"),e.exitFullscreen()});let n=this.player.volume();n=n-1,$("#bar1")[0].style.height=104-n*100+"px",$("#box")[0].style.top=n*100+"px",$("#volumeTitle").text(this.player.volume()*100+"%"),$(".speed").mouseover(function(i){i.stopPropagation(),$(".speeddiv").show(),$(".volumeDiv").hide(),$(".settingdiv").hide()}),$(".volume").mouseover(function(i){i.stopPropagation(),$(".volumeDiv").show(),$(".settingdiv").hide(),$(".speeddiv").hide()}),$(".setting").mouseover(function(i){i.stopPropagation(),$(".settingdiv").show(),$(".volumeDiv").hide(),$(".speeddiv").hide()}),$(".settingdiv").mouseout(function(i){const a=window.event||i;var o=a.toElement||a.relatedTarget,d=this;if(d.contains(o))return!1;$(".settingdiv").hide()}),$(".full").mouseover(function(i){i.stopPropagation(),$(".settingdiv").hide(),$(".volumeDiv").hide(),$(".speeddiv").hide()}),$(".volume").mouseout(function(i){setTimeout(function(){c===0&&$(".volumeDiv").hide()},1e3)});var c=0;$(".volumeDiv").mouseover(function(i){c=1}),$(".volume").click(function(i){$("video").length&&$("video")[0].muted&&($("video")[0].muted=!1),e.player.volume()>0?l():r()}),$(".speeddiv").mouseout(function(i){const a=window.event||i;var o=a.toElement||a.relatedTarget,d=this;if(d.contains(o))return!1;$(".speeddiv").hide()}),$(".volumeDiv").mouseout(function(i){const a=window.event||i;var o=a.toElement||a.relatedTarget,d=this;if(d.contains(o))return!1;$(".volumeDiv").hide(),c=0});var x=new Date().getTime(),w=new Date().getTime(),j=3e3;const T=setInterval(function(){let i=new Date().getTime();const a=$(".playbtn").attr("src").search("play")>-1;i-w>j&&!a&&$(".controls").hide()},3e3);$("#"+this.domId).mouseout(function(i){const a=window.event||i;var o=a.toElement||a.relatedTarget,d=this;if(d.contains(o))return!1;$(".controls").hide()}),$("#"+this.domId).mousemove(function(i){w=new Date().getTime(),$(".controls").show()}),$(".js-video-ratio").click(function(i){const a=$(this),o=a.data("type"),d=$("#wjplayer video");$(".js-video-ratio").removeClass("current"),a.addClass("current");const v="vjs-tech";let u="";switch(d.attr("style",""),o){case"default":{u="pic_default",e.getVideoStyle(e.videoRatio);b
|