filesbox/web/dist/design/designstatic/home/pc/components/player/index.js

2 lines
11 KiB
JavaScript
Raw Normal View History

2024-07-26 06:10:54 +00:00
(function(o,p){if(p.player||!p.loadScriptmin)return!1;p.player={init:function(){var e=this;e.checkVideo(),(o(".player").length>0||window.backvedio!=0&&o(".content").length>0)&&loadScriptmin.apply(e,[(window.cdnPath||"")+"/design/designstatic/home/js/video/video.min.js",function(){loadScriptmin.apply(e,[(window.cdnPath||"")+"/design/designstatic/home/js/video/videojs-contrib-hls.min.js",e.hasVideo])}])},hasVideo:function(){var e=this;if(window.backvedio&&window.backvedio!=0&&o(".content").length>0){e.getBgVedioUrl(),o(".content").css({position:"relative","z-index":"1"});var a={backgroundImage:"url("+bgVideoPic+")",backgroundSize:"100% "+o(window).height()+"px",backgroundRepeat:"no-repeat",backgroundAttachment:"fixed"};o("body").css(a)}e.getVideoDatas(),e.bindPlayerLayer()},checkVideo:function(){var e=this;if(!!document.createElement("video").canPlayType&&e.IEVersion(!0)){var a=document.createElement("video");return oggTest=a.canPlayType('video/ogg; codecs="theora, vorbis"'),oggTest?oggTest=="probably":(h264Test=a.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'),h264Test?h264Test=="probably":!1)}else return!1},IEVersion:function(e){var a=navigator.userAgent,n=a.indexOf("compatible")>-1&&a.indexOf("MSIE")>-1,t=a.indexOf("Edge")>-1&&!n,r=a.indexOf("Trident")>-1&&a.indexOf("rv:11.0")>-1;return n?!1:t||r?!0:e},getBgVedioUrl:function(){var e=this;o.ajax({type:"get",url:"/room/design/getvediourl.html",data:{cwid:backvedio,did:did||0},dataType:"json",success:function(a){a.code<1&&e.carryBgVideo(a.data)}})},carryBgVideo:function(e){var a=this;if(a.IEVersion(!1))a.carryObjectDrawImage(e);else{var n='<video id="backvedio" class="video-js vjs-default-skin" style="display:none;" loop muted playsinline webkit-playsinline controls preload="auto" x-webkit-airplay="true" controlsList="nodownload" oncontextmenu="return false" ><source src="'+(window.cdnPath||"")+e+'" type="application/x-mpegURL"></video>';o("body").append(n),window.videojs("backvedio",{},function(){this.play()}),a.carryCanvasDrawImage()}},carryObjectDrawImage:function(e){var a=o(window).width(),n=o(window).height(),t='<video id="backvedio" class="video-js vjs-default-skin" width="'+a+'" playsinline loop muted webkit-playsinline controls="false" preload="auto" x-webkit-airplay="true" controlsList="nodownload" oncontextmenu="return false" ><source src="'+(window.cdnPath||"")+e+'" type="application/x-mpegURL"></video>';o("body").append(t),o("#backvedio").css({position:"fixed",top:"0",left:"0"}),window.onresize=function(){a=o(window).width(),n=o(window).height()},window.videojs("backvedio",{},function(){this.play(),o("#backvedio .vjs-control-bar").hide()})},carryCanvasDrawImage:function(){var e=document.createElement("canvas");e.id="myCanvas",document.body.appendChild(e);var a=document.getElementById("backvedio_html5_api"),n=document.getElementById("myCanvas"),t=o(window).width(),r=o(window).height();o("#myCanvas").css({position:"fixed",top:"0",left:"0"}),window.onresize=function(){t=o(window).width(),r=o(window).height()},n.width=t,n.height=r;var d=n.getContext("2d");a.addEventListener("play",function(){var s=window.setInterval(function(){d.drawImage(a,0,0,t,r)},20)},!1),a.addEventListener("pause",function(){window.clearInterval(i)},!1),a.addEventListener("ended",function(){clearInterval(i)},!1)},getVideoDatas:function(){var e=this;e.playParams={},e.IEVersion(!1)&&o("head").append("<style>.video-js .vjs-tech, .video-js.vjs-fill{width:auto; max-width:100%;}</style>"),e.playElement=o(".module[data-type=player]"),e.playerdatas=[];for(var a=0,n=e.playElement.length;a<n;a++){var t=e.playElement.eq(a),r=o.parseJSON(t.attr("data-player"));e.getCreateVideoConfig(t,r)}},getCreateVideoConfig:function(e,a){var n=this,n=this,t="player"+e.attr("data-mid");e.find(".box").append('<div id="'+t+'"></div>');var r=parseInt(e.css("width")),d=parseInt(e.css("height"));n.playParams[t]={dom:e,playerId:t,playMenus:a.list,designId:a.designId,autoPlay:a.play,controls:a.controls,playIndex:0,width:r,height:d},n.getVedioUrl(t),e.find("li").on("click",function(){n.playParams[t].playIndex=o(this)