Comments (9)
I took a look, but it seemed to require editing the plugin itself in order to specify any sort of customized keys.
Perhaps you need other custom keys that I haven't built yet, but maybe this format can work better?
https://github.com/ctd1500/videojs-hotkeys/blob/modular/videojs.hotkeys.js
This would allow for easily replacing hotkeys with your own with an option parameter, without requiring editing the plugin script.
For example, replacing / changing the fullscreen hotkey:
this.hotkeys({
volumeStep: 0.2,
enableFullscreen: true,
fullscreenKey: function(e) {
// fullscreen with the F key or Ctrl+Enter
return ((e.which === 70) || (e.ctrlKey && e.which === 13));
}
});
from videojs-hotkeys.
Ok, I give it a try.
In my case I need to provide hotkeys to:
Add new simple hotkey
- Toggle subtitules with S Key
Enhance existing simple hotkey with a complex hotkey
- Toggle FullScreen with CTRL + ENTER
Add new complex hotkey
- Toggle "awesome behaviour " with CTRL + D
I will rewrite my code following your way.
from videojs-hotkeys.
I can change this a little bit, to enable such functionality.
from videojs-hotkeys.
I've just updated the branch.
https://github.com/ctd1500/videojs-hotkeys/blob/modular/videojs.hotkeys.js
Something simple like this could be done.
this.hotkeys({
playPauseKey: function(e, player) {
// spacebar toggle Play/Pause
if (e.which === 32) {
return true;
}
// catch "S" key for subtitles
if (e.which === 83) {
// Toggle subtitles with code here, or call another function you wrote
// Pass the "player" variable which is the current video.js player object.
toggleSubtitles(player);
// return false so that we don't play/pause when toggling subtitles.
return false;
}
return false;
}
});
Or I could also add a new customKey: function(e, player) { }
function to add any new keys without needing to override existing keys.
Something like:
this.hotkeys({
customKey: function(e, player) {
// catch "S" key for subtitles
if (e.which === 83) {
// Toggle subtitles with code here, or call another function you wrote
// Pass the "player" variable which is the current video.js player object.
toggleSubtitles(player);
}
// Wouldn't need to return anything, since the customKey function would
// not do anything by itself.
return;
}
});
from videojs-hotkeys.
Hi,
Checkout my branch:
https://github.com/ReNDeZOwnler/videojs-hotkeys/tree/modular
- videojs.hotkeys.js
- example.html
from videojs-hotkeys.
I just gave it a test run, it seems pretty good to me.
Want to create a pull request? Then I can start putting it into the next release.
from videojs-hotkeys.
Ok, I have some other suggestions.
I'll create a pull request for this a threat the other things in other issues.
from videojs-hotkeys.
You can close this issue when you merge the pull request.
from videojs-hotkeys.
Thanks.
from videojs-hotkeys.
Related Issues (20)
- default page scroll not working HOT 7
- Bug when clicking on pause HOT 3
- Ads/Ima Support HOT 1
- example.html does not work HOT 2
- Not working in new Chrome 69 HOT 2
- The play() request was interrupted by a call to pause().
- Double click fullscreen broken in Safari HOT 1
- Can't resolve 'videojs' in '0.2.25@videojs-hotkeys' HOT 1
- 0.2.25 does not work for player versions such as 6.13.0, 7.3.0, 7.5.0 HOT 11
- alwaysCaptureHotkeys bug HOT 1
- Not working
- this.hotkeys is not a function HOT 17
- use videojs-hotkeys in Angular HOT 2
- Add PictureInPicture hotkey Option
- hotkeys break Media Play Pause key HOT 1
- Uncaught error when pressing fullscreen shortcut with captureDocumentHotkeys set to true and video player focused HOT 1
- Doesn't work with the latest video.js (export/import issue) HOT 2
- [bug] Spacebar hotkey only works every other time hotkeys() is called HOT 3
- Is there a way to enable disable de plugin?
- `videojs.mergeOptions` is deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from videojs-hotkeys.