Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

videojs-hotkeys

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

videojs-hotkeys - npm Package Compare versions

Comparing version 0.2.27 to 0.2.28

{
"name": "videojs-hotkeys",
"version": "0.2.27",
"version": "0.2.28",
"description": "Adds more hotkey support to video.js",
"main": "videojs.hotkeys.min.js",
"author": "Chris Dougherty",
"license": "Apache-2.0",
"main": "videojs.hotkeys.js",
"types": "index.d.ts",
"repository": {

@@ -9,0 +10,0 @@ "type": "git",

@@ -9,2 +9,3 @@ videojs-hotkeys

- [Self hosted](#self-hosted)
- [Npm / Yarn package](#yarn--npm-package)
- **[Enable the plugin](#enable-the-plugin)**

@@ -54,2 +55,15 @@ - **[Options](#options)**

### Yarn / npm package
You can install the package:
```sh
yarn add videojs-hotkeys
# or npm
npm i videojs-hotkeys --save
```
Import it into your project:
```js
import "videojs-hotkeys";
```
### Self hosted

@@ -64,2 +78,14 @@ ```html

```js
videojs('vidId', {
plugins: {
hotkeys: {
volumeStep: 0.1,
seekStep: 5,
enableModifiersForNumbers: false
},
},
});
```
or
```js
videojs('vidId').ready(function() {

@@ -119,10 +145,12 @@ this.hotkeys({

```js
videojs('vidId').ready(function() {
this.hotkeys({
volumeStep: 0.1,
fullscreenKey: function(event, player) {
// override fullscreen to trigger when pressing the F key or Ctrl+Enter
return ((event.which === 70) || (event.ctrlKey && event.which === 13));
}
});
videojs('vidId', {
plugins: {
hotkeys: {
volumeStep: 0.1,
fullscreenKey: function(event, player) {
// override fullscreen to trigger when pressing the F key or Ctrl+Enter
return ((event.which === 70) || (event.ctrlKey && event.which === 13));
}
},
},
});

@@ -138,21 +166,23 @@ ```

```js
videojs('vidId').ready(function() {
this.hotkeys({
volumeStep: 0.1,
customKeys: {
// Create custom hotkeys
ctrldKey: {
key: function(event) {
// Toggle something with CTRL + D Key
return (event.ctrlKey && event.which === 68);
},
handler: function(player, options, event) {
// Using mute as an example
if (options.enableMute) {
player.muted(!player.muted());
videojs('vidId', {
plugins: {
hotkeys: {
volumeStep: 0.1,
customKeys: {
// Create custom hotkeys
ctrldKey: {
key: function(event) {
// Toggle something with CTRL + D Key
return (event.ctrlKey && event.which === 68);
},
handler: function(player, options, event) {
// Using mute as an example
if (options.enableMute) {
player.muted(!player.muted());
}
}
}
}
}
});
},
},
});

@@ -159,0 +189,0 @@ ```

@@ -17,3 +17,4 @@ /*

} else if (typeof module !== 'undefined' && module.exports) {
module.exports = factory(require('video.js'));
var videojs = require('video.js');
module.exports = factory(videojs.default || videojs);
}

@@ -23,3 +24,3 @@ }(this, function (videojs) {

if (typeof window !== 'undefined') {
window['videojs_hotkeys'] = { version: "0.2.27" };
window['videojs_hotkeys'] = { version: "0.2.28" };
}

@@ -426,3 +427,13 @@

player.on('keydown', keyDown);
if (captureDocumentHotkeys) {
var capDocHK = function (event) { keyDown(event) };
document.addEventListener('keydown', capDocHK);
this.dispose = function () {
document.removeEventListener('keydown', capDocHK);
}
} else {
player.on('keydown', keyDown);
}
player.on('dblclick', doubleClick);

@@ -432,6 +443,2 @@ player.on('mousewheel', mouseScroll);

if (captureDocumentHotkeys) {
document.addEventListener('keydown', function (event) { keyDown(event) });
}
return this;

@@ -438,0 +445,0 @@ };

@@ -1,2 +0,2 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet