From: Chocobozzz <me@florianbigard.com>
Date: Thu, 4 Jun 2020 14:06:03 +0000 (+0200)
Subject: Support player hotkeys when it is not focused
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7ede74add2d41958f3aad0053afc812698f261a0;p=oweals%2Fpeertube.git

Support player hotkeys when it is not focused
---

diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts
index 5b0b34c80..933e6c51f 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -467,7 +467,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
     this.zone.runOutsideAngular(async () => {
       this.player = await PeertubePlayerManager.initialize(playerMode, playerOptions, player => this.player = player)
-      this.player.focus()
 
       this.player.on('customError', ({ err }: { err: any }) => this.handleError(err))
 
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index ebb1e454a..630eebbca 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -452,6 +452,13 @@ export class PeertubePlayerManager {
   private static addHotkeysOptions (plugins: VideoJSPluginOptions) {
     Object.assign(plugins, {
       hotkeys: {
+        skipInitialFocus: true,
+        enableInactiveFocus: false,
+        captureDocumentHotkeys: true,
+        documentHotkeysFocusElementFilter: (e: HTMLElement) => {
+          return e.id === 'content' || e.tagName.toLowerCase() === 'body'
+        },
+
         enableVolumeScroll: false,
         enableModifiersForNumbers: false,