-
Notifications
You must be signed in to change notification settings - Fork 106
/
videojs.hotkeys.min.js
2 lines (2 loc) · 4.42 KB
/
videojs.hotkeys.min.js
1
2
/* videojs-hotkeys v0.2.30 - https://github.com/ctd1500/videojs-hotkeys */
(t=>{var e;"undefined"!=typeof window&&window.videojs?t(window.videojs):"function"==typeof define&&define.amd?define("videojs-hotkeys",["video.js"],function(e){return t(e.default||e)}):"undefined"!=typeof module&&module.exports&&(e=require("video.js"),module.exports=t(e.default||e))})(function(I){"undefined"!=typeof window&&(window.videojs_hotkeys={version:"0.2.30"});(I.registerPlugin||I.plugin)("hotkeys",function(a){function e(e){var t;t=u?0:y.activeElement,s.controls()&&(q||t==m||t==m.querySelector(".vjs-tech")||t==m.querySelector(".iframeblocker")||t==m.querySelector(".vjs-control-bar")||x)&&r&&(e=window.event||e,t=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault(),1==t?s.volume(s.volume()+k):-1==t&&s.volume(s.volume()-k))}var t,s=this,m=s.el(),y=document,d=1,v=2,f=3,p=4,b=5,h=6,w=7,n=I.obj?.merge||I.mergeOptions||I.util.mergeOptions,k=(a=n({volumeStep:.1,seekStep:5,enableMute:!0,enableVolumeScroll:!0,enableHoverScroll:!1,enableFullscreen:!0,enableNumbers:!0,enableJogStyle:!1,alwaysCaptureHotkeys:!1,captureDocumentHotkeys:!1,documentHotkeysFocusElementFilter:()=>!1,enableModifiersForNumbers:!0,enableInactiveFocus:!0,skipInitialFocus:!1,playPauseKey:function(e){return 32===e.which||179===e.which},rewindKey:function(e){return 37===e.which||177===e.which},forwardKey:function(e){return 39===e.which||176===e.which},volumeUpKey:function(e){return 38===e.which},volumeDownKey:function(e){return 40===e.which},muteKey:function(e){return 77===e.which},fullscreenKey:function(e){return 70===e.which},customKeys:{}},a||{})).volumeStep,o=a.seekStep,S=a.enableMute,r=a.enableVolumeScroll,u=a.enableHoverScroll,K=a.enableFullscreen,F=a.enableNumbers,j=a.enableJogStyle,q=a.alwaysCaptureHotkeys,E=a.captureDocumentHotkeys,T=a.documentHotkeysFocusElementFilter,g=a.enableModifiersForNumbers,n=a.enableInactiveFocus,l=a.skipInitialFocus,i=I.VERSION,c=(m.hasAttribute("tabIndex")||m.setAttribute("tabIndex","-1"),m.style.outline="none",!q&&s.autoplay()||l||s.one("play",()=>{m.focus()}),n&&s.on("userinactive",()=>{var o=()=>{clearTimeout(e)},e=setTimeout(()=>{s.off("useractive",o);var e=y.activeElement,t=e.parentElement,n=m.querySelector(".vjs-control-bar");!e||n!=t&&n!=t.parentElement||m.focus()},10);s.one("useractive",o)}),s.on("play",()=>{var e=m.querySelector(".iframeblocker");e&&""===e.style.display&&(e.style.display="block",e.style.bottom="39px")}),function(e){var t=e.which,n=e.preventDefault.bind(e),o=s.duration();if(s.controls()){var r,u,l,i=y.activeElement;if(q||E&&T(i)||i==m||i==m.querySelector(".vjs-tech")||i==m.querySelector(".vjs-control-bar")||i==m.querySelector(".iframeblocker"))switch(D(e,s)){case d:n(),(q||E)&&e.stopPropagation(),s.paused()?M(s.play()):s.pause();break;case v:r=!s.paused(),n(),r&&s.pause(),u=s.currentTime()-H(e),s.currentTime(u=u<=0?0:u),r&&M(s.play());break;case f:r=!s.paused(),n(),r&&s.pause(),u=s.currentTime()+H(e),s.currentTime(u=o<=u?r?o-.001:o:u),r&&M(s.play());break;case b:n(),j?(u=s.currentTime()-1,s.currentTime()<=1&&(u=0),s.currentTime(u)):s.volume(s.volume()-k);break;case p:n(),j?(u=s.currentTime()+1,s.currentTime(u=o<=u?o:u)):s.volume(s.volume()+k);break;case h:S&&s.muted(!s.muted());break;case w:K&&(s.isFullscreen()?s.exitFullscreen():s.requestFullscreen());break;default:for(l in!(47<t&&t<59||95<t&&t<106)||!g&&(e.metaKey||e.ctrlKey||e.altKey)||F&&(r=48,u=t-(r=95<t?96:r),n(),s.currentTime(s.duration()*u*.1)),a.customKeys){var c=a.customKeys[l];c&&c.key&&c.handler&&c.key(e)&&(n(),c.handler(s,a,e))}}}}),x=!1,l=m.querySelector(".vjs-volume-menu-button")||m.querySelector(".vjs-volume-panel"),D=(null!=l&&(l.addEventListener("mouseover",()=>{x=!0}),l.addEventListener("mouseout",()=>{x=!1})),function(e,t){return a.playPauseKey(e,t)?d:a.rewindKey(e,t)?v:a.forwardKey(e,t)?f:a.volumeUpKey(e,t)?p:a.volumeDownKey(e,t)?b:a.muteKey(e,t)?h:a.fullscreenKey(e,t)?w:void 0});function H(e){return"function"==typeof o?o(e):o}function M(e){null!=e&&"function"==typeof e.then&&e.then(null,function(e){})}return E?(t=function(e){c(e)},document.addEventListener("keydown",t),this.dispose=()=>{document.removeEventListener("keydown",t)}):s.on("keydown",c),s.on("dblclick",function(e){null!=i&&i<="7.1.0"&&(!s.controls()||(e=e.relatedTarget||e.toElement||y.activeElement)!=m&&e!=m.querySelector(".vjs-tech")&&e!=m.querySelector(".iframeblocker")||K&&(s.isFullscreen()?s.exitFullscreen():s.requestFullscreen()))}),s.on("mousewheel",e),s.on("DOMMouseScroll",e),this})});