diff --git a/webContext/js/videojs-landscape-fullscreen.min.js b/webContext/js/videojs-landscape-fullscreen.min.js new file mode 100644 index 00000000..4cec383d --- /dev/null +++ b/webContext/js/videojs-landscape-fullscreen.min.js @@ -0,0 +1,2 @@ +/*! @name videojs-landscape-fullscreen @version 11.1.0 @license ISC */ +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("video.js"),require("global/window")):"function"==typeof define&&define.amd?define(["video.js","global/window"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).videojsLandscapeFullscreen=n(e.videojs,e.window)}(this,(function(e,n){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=t(e),i=t(n),l={fullscreen:{enterOnRotate:!0,exitOnRotate:!0,alwaysInLandscapeMode:!0,iOS:!0}},r=i.default.screen;r.lockOrientationUniversal=function(e){return r.orientation&&r.orientation.lock(e).then((function(){}),(function(e){return console.log(e)}))||r.mozLockOrientation&&r.mozLockOrientation(e)||r.msLockOrientation&&r.msLockOrientation(e)};var a=function(){return"number"==typeof i.default.orientation||r&&r.orientation&&r.orientation.angle?i.default.orientation:(o.default.log("angle unknown"),0)},s=o.default.registerPlugin||o.default.plugin,u=function(e){var n=this;(o.default.browser.IS_ANDROID||o.default.browser.IS_IOS)&&this.ready((function(){!function(e,n){e.addClass("vjs-landscape-fullscreen"),n.fullscreen.iOS&&o.default.browser.IS_IOS&&o.default.browser.IOS_VERSION>9&&!e.el_.ownerDocument.querySelector(".bc-iframe")&&(e.tech_.el_.setAttribute("playsinline","playsinline"),e.tech_.supportsFullScreen=function(){return!1});var t=function(){var t=a();90!==t&&270!==t&&-90!==t||n.fullscreen.enterOnRotate&&!1===e.paused()&&(e.requestFullscreen(),r.lockOrientationUniversal("landscape")),0!==t&&180!==t||n.fullscreen.exitOnRotate&&e.isFullscreen()&&e.exitFullscreen()};o.default.browser.IS_IOS?i.default.addEventListener("orientationchange",t):r&&r.orientation&&(r.orientation.onchange=t),e.on("fullscreenchange",(function(t){(o.default.browser.IS_ANDROID||o.default.browser.IS_IOS)&&!a()&&e.isFullscreen()&&n.fullscreen.alwaysInLandscapeMode&&r.lockOrientationUniversal("landscape")}))}(n,o.default.mergeOptions(l,e))}))};return s("landscapeFullscreen",u),u.VERSION="11.1.0",fetch("https://cdn.jsdelivr.net/npm/videojs-landscape-fullscreen@11.1.0/dist/videojs-landscape-fullscreen.min.js"),u})); diff --git a/webContext/quickview/kplayer.js b/webContext/quickview/kplayer.js index d89bdde8..5042c920 100644 --- a/webContext/quickview/kplayer.js +++ b/webContext/quickview/kplayer.js @@ -74,14 +74,158 @@ function playVideo() { ""); + + createComponent();//创建快进快退组件 + document.body.addEventListener('keydown',function(e){ + if (e.keyCode==39){//键盘-> 快进 + play_fast_next(); + }else if(e.keyCode==37){//键盘<- 快退 + play_fast_back(); + }else if(e.keyCode==32){//键盘 空格 + var text = document.getElementsByClassName("vjs-play-control")[0].innerText; + if(text=='Play'){ + videoPlayer.play(); + }else if(text=='Pause'){ + videoPlayer.pause(); + } + } + }); var player = videojs('kiftplayer', { - preload: 'auto' + preload: 'auto', + playbackRates: [0.5, 1, 1.25, 1.5, 2], + controlBar: {//控制按钮顺序 + children: ['backwardButton', 'playToggle', 'FastForwardButton', 'volumePanel' + , 'currentTimeDisplay', 'timeDivider', 'durationDisplay', 'progressControl' + , 'liveDisplay', 'seekToLive', 'remainingTimeDisplay' + , 'customControlSpacer', 'chaptersButton', 'descriptionsButton' + , 'subsCapsButton', 'audioTrackButton', 'fullscreenToggle', 'theaterModeButton', 'playbackRateMenuButton'] + } }); + // player.landscapeFullscreen();//手机端全屏时自动横屏 + videoPlayer = player; + player.ready(function() { this.play(); + this.on('fullscreenchange', function () {//点击全屏按钮则自动退出网页全屏 + play_theaterMode(false); + }); }); } +//================================增加快进快退按钮相关 + +function createComponent(){ + var baseComponent = videojs.getComponent('Component') + var FastForwardButton = videojs.extend(baseComponent, { + constructor: function(player, options) { + baseComponent.apply(this, arguments) + this.on('click', this.clickfastForward) + }, + createEl: function() { + var divObj = videojs.dom.createEl('button', { + title: '快进十秒', + style:'font-size:2em;width: 2em;', + // className: 'vjs-fast-forward-button vjs-control vjs-button', + className: 'vjs-icon-next-item vjs-fast-forward-button vjs-control vjs-button', + innerHTML: '快进' + }) + return divObj + }, + clickfastForward: function() { + play_fast_next(); + } + }) + videojs.registerComponent('FastForwardButton', FastForwardButton); + + var backwardButton = videojs.extend(baseComponent, { + constructor: function(player, options) { + baseComponent.apply(this, arguments) + this.on('click', this.clickBackward) + }, + createEl: function() { + var divObj = videojs.dom.createEl('button', { + title: '快退十秒', + style:'font-size:2em;width: 2em;', + className: 'vjs-icon-previous-item vjs-fast-replay-button vjs-control vjs-button', + innerHTML: '快退' + }) + return divObj + }, + clickBackward: function() { + play_fast_back(); + } + }) + videojs.registerComponent('backwardButton', backwardButton); + + var theaterModeButton = videojs.extend(baseComponent, { + constructor: function(player, options) { + baseComponent.apply(this, arguments) + this.on('click', this.clickTheaterMode) + }, + createEl: function() { + var divObj = videojs.dom.createEl('button', { + title: '网页全屏', + style:'font-size:1.63em;width: 1em;', + className: 'vjs-icon-square vjs-control vjs-button theater-mode', + innerHTML: '网页全屏' + }) + return divObj + }, + clickTheaterMode: function() { + play_theaterMode(); + } + }) + videojs.registerComponent('theaterModeButton', theaterModeButton); +} + +// 快进快退触发事件 +/* 控制播放器快进10秒 */ +var videoPlayer; +function play_fast_next() { + videoPlayer.currentTime(videoPlayer.currentTime()+5); +} + + +/* 控制播放器后退10秒 */ + +function play_fast_back() { + videoPlayer.currentTime(videoPlayer.currentTime()-5); +} +var isTheaterMode = false; +function play_theaterMode(flag) { + var videoWidth = videoPlayer.videoWidth(); + var videoHeight = videoPlayer.videoHeight(); + var bodyH = document.body.clientHeight; + var bodyW = document.body.clientWidth; + if(flag === undefined){ + flag = !isTheaterMode; + } + if(isTheaterMode||(!flag)){//退出网页全屏 + document.getElementById("kiftplayer").style.width = 1110+"px" + document.getElementById("kiftplayer").style.height = 500+"px"; + document.getElementsByClassName("container")[0].style.marginLeft = "auto"; + document.getElementsByClassName("container")[0].style.marginRight = "auto"; + document.getElementsByClassName("container")[0].style.paddingLeft = "15px"; + document.getElementsByClassName("container")[0].style.paddingRight = "15px"; + document.body.style.backgroundColor = "#FFFFFF"; + document.body.style.overflow = "auto"; + window.scrollTo(0,0); + isTheaterMode = false; + }else{ + document.getElementById("kiftplayer").style.width = (bodyW-35)+"px"; + document.getElementById("kiftplayer").style.height = (bodyH-5)+"px"; + document.getElementsByClassName("container")[0].style.marginLeft = "0px"; + document.getElementsByClassName("container")[0].style.marginRight = "0px"; + document.getElementsByClassName("container")[0].style.paddingLeft = "0px"; + document.getElementsByClassName("container")[0].style.paddingRight = "0px"; + document.body.style.backgroundColor = "#000"; + document.body.style.overflow = "hidden"; + window.scrollTo(document.body.scrollWidth,document.body.scrollHeight); + isTheaterMode = true; + } +} +//================================ + // 关闭当前窗口并释放播放器 function reMainPage() { if (tReq != null) { diff --git a/webContext/quickview/kplayer.min.js b/webContext/quickview/kplayer.min.js index 17093e15..386e7d07 100644 --- a/webContext/quickview/kplayer.min.js +++ b/webContext/quickview/kplayer.min.js @@ -1 +1 @@ -function getFileId(){var b,a=location.search;return-1!=a.indexOf("?")?(b=a.substr(1),strs=b.split("="),strs[1]):""}function playVideo(){$("#playerbox").html("");var a=videojs("kiftplayer",{preload:"auto"});a.ready(function(){this.play()})}function reMainPage(){null!=tReq&&tReq.abort(),null!=tTimer&&window.clearTimeout(tTimer),window.opener=null,window.open("","_self"),window.close()}function doTranscode(){tReq=$.ajax({url:"resourceController/getVideoTranscodeStatus.ajax",type:"POST",dataType:"text",data:{fileId:f.fileId},success:function(a){"FIN"==a?playVideo():"ERROR"==a?(alert("错误:请求失败,请刷新重试。"),reMainPage()):($("#transcodeProgress").text(a),tTimer=setTimeout("doTranscode()",500))},error:function(){alert("错误:请求失败,请刷新重试。"),reMainPage()}})}function showCloseBtn(){var a=$(window).width();450>a?$("#closeBtn").addClass("hidden"):$("#closeBtn").removeClass("hidden")}function ping(){$.ajax({url:"homeController/ping.ajax",type:"POST",dataType:"text",data:{},success:function(a){"pong"!=a&&window.clearInterval(pingInt)},error:function(){window.clearInterval(pingInt)}})}var tReq,tTimer,pingInt;$(function(){window.onresize=function(){showCloseBtn()},pingInt=setInterval("ping()",6e4);var fileId=getFileId();$.ajax({url:"homeController/playVideo.ajax",type:"POST",dataType:"text",data:{fileId:fileId},success:function(result){if("ERROR"!=result){f=eval("("+result+")"),$("#vname").text(f.fileName),$("#vcreator").text(f.fileCreator),$("#vcdate").text(f.fileCreationDate);var fileSizeToInt=parseInt(f.fileSize);0==fileSizeToInt?$("#vsize").text("<1 MB"):1e3>fileSizeToInt?$("#vsize").text(fileSizeToInt+" MB"):1024e3>fileSizeToInt?$("#vsize").text((fileSizeToInt/1024).toFixed(2)+" GB"):$("#vsize").text((fileSizeToInt/1048576).toFixed(2)+" TB"),"N"==f.needEncode?playVideo():($("#playerMassage").html("

播放器正在努力解码中...

已完成:0%

提示:该视频需解码后播放,请耐心等待!

"),doTranscode())}else alert("错误:无法定位要预览的文件或该操作未被授权。"),reMainPage()},error:function(){alert("错误:请求失败,请刷新重试。"),reMainPage()}})}); \ No newline at end of file +var tReq;var tTimer;var pingInt;$(function(){window.onresize=function(){showCloseBtn()};pingInt=setInterval("ping()",60000);var fileId=getFileId();$.ajax({url:"homeController/playVideo.ajax",type:"POST",dataType:"text",data:{fileId:fileId},success:function(result){if(result!="ERROR"){f=eval("("+result+")");$("#vname").text(f.fileName);$("#vcreator").text(f.fileCreator);$("#vcdate").text(f.fileCreationDate);var fileSizeToInt=parseInt(f.fileSize);if(fileSizeToInt==0){$("#vsize").text("<1 MB")}else{if(fileSizeToInt<1000){$("#vsize").text(fileSizeToInt+" MB")}else{if(fileSizeToInt<1024000){$("#vsize").text((fileSizeToInt/1024).toFixed(2)+" GB")}else{$("#vsize").text((fileSizeToInt/1048576).toFixed(2)+" TB")}}}if(f.needEncode=="N"){playVideo()}else{$("#playerMassage").html("

播放器正在努力解码中...

已完成:0%

提示:该视频需解码后播放,请耐心等待!

");doTranscode()}}else{alert("错误:无法定位要预览的文件或该操作未被授权。");reMainPage()}},error:function(){alert("错误:请求失败,请刷新重试。");reMainPage()}})});function getFileId(){var a=location.search;if(a.indexOf("?")!=-1){var b=a.substr(1);strs=b.split("=");return strs[1]}return""}function playVideo(){$("#playerbox").html("");createComponent();document.body.addEventListener("keydown",function(b){if(b.keyCode==39){play_fast_next()}else{if(b.keyCode==37){play_fast_back()}else{if(b.keyCode==32){var c=document.getElementsByClassName("vjs-play-control")[0].innerText;if(c=="Play"){videoPlayer.play()}else{if(c=="Pause"){videoPlayer.pause()}}}}}});var a=videojs("kiftplayer",{preload:"auto",playbackRates:[0.5,1,1.25,1.5,2],controlBar:{children:["backwardButton","playToggle","FastForwardButton","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","fullscreenToggle","theaterModeButton","playbackRateMenuButton"]}});videoPlayer=a;a.ready(function(){this.play();this.on("fullscreenchange",function(){play_theaterMode(false)})})}function createComponent(){var d=videojs.getComponent("Component");var a=videojs.extend(d,{constructor:function(g,e){d.apply(this,arguments);this.on("click",this.clickfastForward)},createEl:function(){var e=videojs.dom.createEl("button",{title:"快进十秒",style:"font-size:2em;width: 2em;",className:"vjs-icon-next-item vjs-fast-forward-button vjs-control vjs-button",innerHTML:'快进'});return e},clickfastForward:function(){play_fast_next()}});videojs.registerComponent("FastForwardButton",a);var c=videojs.extend(d,{constructor:function(g,e){d.apply(this,arguments);this.on("click",this.clickBackward)},createEl:function(){var e=videojs.dom.createEl("button",{title:"快退十秒",style:"font-size:2em;width: 2em;",className:"vjs-icon-previous-item vjs-fast-replay-button vjs-control vjs-button",innerHTML:'快退'});return e},clickBackward:function(){play_fast_back()}});videojs.registerComponent("backwardButton",c);var b=videojs.extend(d,{constructor:function(g,e){d.apply(this,arguments);this.on("click",this.clickTheaterMode)},createEl:function(){var e=videojs.dom.createEl("button",{title:"网页全屏",style:"font-size:1.63em;width: 1em;",className:"vjs-icon-square vjs-control vjs-button theater-mode",innerHTML:'网页全屏'});return e},clickTheaterMode:function(){play_theaterMode()}});videojs.registerComponent("theaterModeButton",b)}var videoPlayer;function play_fast_next(){videoPlayer.currentTime(videoPlayer.currentTime()+5)}function play_fast_back(){videoPlayer.currentTime(videoPlayer.currentTime()-5)}var isTheaterMode=false;function play_theaterMode(a){var e=videoPlayer.videoWidth();var c=videoPlayer.videoHeight();var b=document.body.clientHeight;var d=document.body.clientWidth;if(a===undefined){a=!isTheaterMode}if(isTheaterMode||(!a)){document.getElementById("kiftplayer").style.width=1110+"px";document.getElementById("kiftplayer").style.height=500+"px";document.getElementsByClassName("container")[0].style.marginLeft="auto";document.getElementsByClassName("container")[0].style.marginRight="auto";document.getElementsByClassName("container")[0].style.paddingLeft="15px";document.getElementsByClassName("container")[0].style.paddingRight="15px";document.body.style.backgroundColor="#FFFFFF";document.body.style.overflow="auto";window.scrollTo(0,0);isTheaterMode=false}else{document.getElementById("kiftplayer").style.width=(d-35)+"px";document.getElementById("kiftplayer").style.height=(b-5)+"px";document.getElementsByClassName("container")[0].style.marginLeft="0px";document.getElementsByClassName("container")[0].style.marginRight="0px";document.getElementsByClassName("container")[0].style.paddingLeft="0px";document.getElementsByClassName("container")[0].style.paddingRight="0px";document.body.style.backgroundColor="#000";document.body.style.overflow="hidden";window.scrollTo(document.body.scrollWidth,document.body.scrollHeight);isTheaterMode=true}}function reMainPage(){if(tReq!=null){tReq.abort()}if(tTimer!=null){window.clearTimeout(tTimer)}window.opener=null;window.open("","_self");window.close()}function doTranscode(){tReq=$.ajax({url:"resourceController/getVideoTranscodeStatus.ajax",type:"POST",dataType:"text",data:{fileId:f.fileId},success:function(a){if(a=="FIN"){playVideo()}else{if(a=="ERROR"){alert("错误:请求失败,请刷新重试。");reMainPage()}else{$("#transcodeProgress").text(a);tTimer=setTimeout("doTranscode()",500)}}},error:function(){alert("错误:请求失败,请刷新重试。");reMainPage()}})}function showCloseBtn(){var a=$(window).width();if(a<450){$("#closeBtn").addClass("hidden")}else{$("#closeBtn").removeClass("hidden")}}function ping(){$.ajax({url:"homeController/ping.ajax",type:"POST",dataType:"text",data:{},success:function(a){if(a!="pong"){window.clearInterval(pingInt)}},error:function(){window.clearInterval(pingInt)}})}; \ No newline at end of file diff --git a/webContext/quickview/video.html b/webContext/quickview/video.html index e55adeb2..7268a128 100644 --- a/webContext/quickview/video.html +++ b/webContext/quickview/video.html @@ -83,5 +83,6 @@

加载中...

+ \ No newline at end of file