]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix playback rate hotkey
authorChocobozzz <me@florianbigard.com>
Mon, 24 Sep 2018 15:44:50 +0000 (17:44 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 24 Sep 2018 15:44:50 +0000 (17:44 +0200)
client/src/assets/player/peertube-player.ts
client/src/assets/player/settings-menu-item.ts

index 5cea69eb81e97e5089f8507221dfafa44f1b2f20..2c16c87eca0a37452b21291918341dcc5747c40f 100644 (file)
@@ -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))
             }
           }
         }
index f6cf6d0f3709833e37112bbc7495e54408d76ef8..665ce6fc2069146bc27683ab9965b1cba81304da 100644 (file)
@@ -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
     }