From 5363a766d95ed8654ad3e1b94538f085c2a3a101 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 24 Sep 2018 17:44:50 +0200 Subject: Fix playback rate hotkey --- client/src/assets/player/peertube-player.ts | 14 ++++++-------- client/src/assets/player/settings-menu-item.ts | 6 +++++- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'client/src/assets') diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 5cea69eb8..2c16c87ec 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts @@ -73,20 +73,18 @@ function getVideojsOptions (options: { customKeys: { increasePlaybackRateKey: { key: function (event) { - // use '>' - return event.which === 51 + return event.key === '>' }, - handler: function (player, options, event) { - player.playbackRate(player.playbackRate() + 0.1) + handler: function (player) { + player.playbackRate((player.playbackRate() + 0.1).toFixed(2)) } }, decreasePlaybackRateKey: { key: function (event) { - // use '<' - return event.which === 50 + return event.key === '<' }, - handler: function (player, options, event) { - player.playbackRate(player.playbackRate() - 0.1) + handler: function (player) { + player.playbackRate((player.playbackRate() - 0.1).toFixed(2)) } } } diff --git a/client/src/assets/player/settings-menu-item.ts b/client/src/assets/player/settings-menu-item.ts index f6cf6d0f3..665ce6fc2 100644 --- a/client/src/assets/player/settings-menu-item.ts +++ b/client/src/assets/player/settings-menu-item.ts @@ -41,6 +41,10 @@ class SettingsMenuItem extends MenuItem { // Voodoo magic for IOS setTimeout(() => { this.build() + + // Update on rate change + player.on('ratechange', this.submenuClickHandler) + this.reset() }, 0) }) @@ -60,7 +64,7 @@ class SettingsMenuItem extends MenuItem { target = event.currentTarget } - if (target.classList.contains('vjs-back-button')) { + if (target && target.classList.contains('vjs-back-button')) { this.loadMainMenu() return } -- cgit v1.2.3