我正在通过修改源代码来构建自己的基于videojs的媒体播放器。我现在想做的是绑定我自己的快捷键,但是很明显videojs已经提前设置了一些快捷键。为了绑定我自己的键盘快捷键,我需要删除videojs中设置的默认快捷键。
如何解绑/移除videojs设置的键盘快捷键?
发布于 2017-04-23 10:18:40
在代码中,我发现了:
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,witch是来自太空的密钥码。玩家只使用回车和空格两个快捷键。所以我推荐了下面这几行:
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
}
};唯一的问题是,当你点击全屏图标并按下空格键时,它将退出全屏模式。但其余的都被删除了。例如播放/暂停、静音和字幕。我希望它能帮上忙!并且为我糟糕的英语感到抱歉。
编辑:在video.js导入后,我通过以下代码解决了这个问题:
$('.vjs-fullscreen-control').click(function(){
setTimeout(function(){
document.getElementById('example_video1').focus();
},20);
});https://stackoverflow.com/questions/39553572
复制相似问题