mirror of
https://github.com/DIYgod/DPlayer
synced 2024-11-22 18:56:54 +00:00
New option: hotkey; Fix hotkey bug
This commit is contained in:
parent
c5c9188e4d
commit
a70b1229ab
@ -50,6 +50,7 @@ var option = {
|
||||
loop: true, // Optional, loop play music, default: true
|
||||
lang: 'zh', // Optional, language, `zh` for Chinese, `en` for English, default: Navigator language
|
||||
screenshot: true, // Optional, enable screenshot function, default: false, NOTICE: if set it to true, video and video poster must enable Cross-Origin
|
||||
hotkey: true, // Optional, binding hot key, including left right and Space, default: true
|
||||
video: { // Required, video info
|
||||
url: '若能绽放光芒.mp4', // Required, video url
|
||||
pic: '若能绽放光芒.png' // Optional, music picture
|
||||
|
@ -62,6 +62,7 @@
|
||||
theme: '#FADFA3',
|
||||
loop: true,
|
||||
screenshot: true,
|
||||
hotkey: true,
|
||||
video: {
|
||||
url: 'http://devtest.qiniudn.com/若能绽放光芒.mp4',
|
||||
pic: 'http://devtest.qiniudn.com/若能绽放光芒.png'
|
||||
|
4
dist/DPlayer.min.js
vendored
4
dist/DPlayer.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/DPlayer.min.js.map
vendored
2
dist/DPlayer.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dplayer",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "Wow, such a lovely HTML5 danmaku video player",
|
||||
"main": "dist/DPlayer.min.js",
|
||||
"scripts": {
|
||||
|
@ -1,4 +1,4 @@
|
||||
console.log("\n %c DPlayer 1.0.5 %c http://dplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");
|
||||
console.log("\n %c DPlayer 1.0.6 %c http://dplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");
|
||||
|
||||
require('./DPlayer.scss');
|
||||
|
||||
@ -48,7 +48,8 @@ class DPlayer {
|
||||
theme: '#b7daff',
|
||||
loop: false,
|
||||
lang: navigator.language.indexOf('zh') !== -1 ? 'zh' : 'en',
|
||||
screenshot: false
|
||||
screenshot: false,
|
||||
hotkey: true
|
||||
};
|
||||
for (let defaultKey in defaultOption) {
|
||||
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
|
||||
@ -1143,7 +1144,9 @@ class DPlayer {
|
||||
* hot key
|
||||
*/
|
||||
const handleKeyDown = (e) => {
|
||||
if (document.activeElement.tagName.toUpperCase() !== 'INPUT') {
|
||||
const tag = document.activeElement.tagName.toUpperCase();
|
||||
const editable = document.activeElement.getAttribute('contenteditable');
|
||||
if (tag !== 'INPUT' && tag !== 'TEXTAREA' && editable !== '' && editable !== 'true') {
|
||||
const event = e || window.event;
|
||||
let percentage;
|
||||
switch (event.keyCode) {
|
||||
@ -1172,7 +1175,9 @@ class DPlayer {
|
||||
}
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
if (option.hotkey) {
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
}
|
||||
|
||||
/**
|
||||
* right key
|
||||
|
Loading…
Reference in New Issue
Block a user