]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/assets/player/peertube-plugin.ts
Fix player menu on mobile
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-plugin.ts
index afd8d678b8258325da96bf86ea796b0c7a4d8864..a2b038b775693792813505ee6fb8e73c13a456be 100644 (file)
@@ -1,4 +1,4 @@
-import videojs from 'video.js/dist/alt/video.core'
+import videojs from 'video.js'
 import './videojs-components/settings-menu-button'
 import {
   PeerTubePluginOptions,
@@ -45,7 +45,7 @@ class PeerTubePlugin extends Plugin {
 
     this.savedInactivityTimeout = player.options_.inactivityTimeout
 
-    if (options.autoplay === true) this.player.addClass('vjs-has-autoplay')
+    if (options.autoplay) this.player.addClass('vjs-has-autoplay')
 
     this.player.on('autoplay-failure', () => {
       this.player.removeClass('vjs-has-autoplay')
@@ -233,12 +233,20 @@ class PeerTubePlugin extends Plugin {
   }
 
   private alterInactivity () {
-    if (this.menuOpened || this.mouseInControlBar) {
+    if (this.menuOpened) {
       this.player.options_.inactivityTimeout = this.savedInactivityTimeout
       return
     }
 
-    this.player.options_.inactivityTimeout = 1
+    if (!this.mouseInControlBar && !this.isTouchEnabled()) {
+      this.player.options_.inactivityTimeout = 1
+    }
+  }
+
+  private isTouchEnabled () {
+    return ('ontouchstart' in window) ||
+      navigator.maxTouchPoints > 0 ||
+      navigator.msMaxTouchPoints > 0
   }
 
   private initCaptions () {