1
我正在通过修改源代码基于videojs构建自己的媒体播放器。我现在想要做的是绑定自己的键盘快捷键,但显然videojs提前设置了一些快捷键。为了绑定我自己的键盘快捷键,我需要删除videojs中设置的默认快捷键。在videojs中,如何解除由videojs设置的键盘快捷键?
如何取消绑定/删除videojs设置的键盘快捷键?
我正在通过修改源代码基于videojs构建自己的媒体播放器。我现在想要做的是绑定自己的键盘快捷键,但显然videojs提前设置了一些快捷键。为了绑定我自己的键盘快捷键,我需要删除videojs中设置的默认快捷键。在videojs中,如何解除由videojs设置的键盘快捷键?
如何取消绑定/删除videojs设置的键盘快捷键?
在代码中,我发现这一点:
ClickableComponent.prototype.handleKeyPress = function handleKeyPress(event) {
// Support Space (32) or Enter (13) key operation to fire a click event
if (event.which === 32 || event.which === 13) {
event.preventDefault();
this.handleClick(event);
} else if (_Component.prototype.handleKeyPress) {
_Component.prototype.handleKeyPress.call(this, event); // Pass keypress handling up for unsupported keys
}
};
我只是在寻找32巫婆是从空间的键码。玩家只使用两个快捷键输入和空格。因此,我赞扬线这样的:
ClickableComponent.prototype.handleKeyPress = function handleKeyPress(event) {
// Support Space (32) or Enter (13) key operation to fire a click event
if (event.which === 32 || event.which === 13) {
//event.preventDefault();
//this.handleClick(event);
} else if (_Component.prototype.handleKeyPress) {
//_Component.prototype.handleKeyPress.call(this, event); // Pass keypress handling up for unsupported keys
}
};
唯一的问题是,当你点击全屏图标,然后按空格键将退出全屏模式。但其余的被删除。像播放/暂停,静音和标题。我希望它有帮助!抱歉我的英文不好。
编辑:
$('.vjs-fullscreen-control').click(function(){
setTimeout(function(){
document.getElementById('example_video1').focus();
},20);
});
: 我用的Video.js进口此代码后解决了这个问题