Disable auto resolution on HTTP fallback
authorChocobozzz <me@florianbigard.com>
Fri, 22 Jun 2018 13:06:33 +0000 (15:06 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 22 Jun 2018 13:11:04 +0000 (15:11 +0200)
client/src/assets/player/peertube-videojs-plugin.ts
client/src/assets/player/resolution-menu-button.ts
client/src/assets/player/resolution-menu-item.ts
client/src/sass/player/settings-menu.scss

index fc07c35d61eca44fdead9fb29d2d9b21bd8720ec..208105d3c29c009a66b1e821fd86bae2640c9e18 100644 (file)
@@ -57,6 +57,7 @@ class PeerTubePlugin extends Plugin {
   private renderer
   private fakeRenderer
   private autoResolution = true
+  private forbidAutoResolution = false
   private isAutoResolutionObservation = false
 
   private videoViewInterval
@@ -304,11 +305,17 @@ class PeerTubePlugin extends Plugin {
     this.trigger('autoResolutionUpdate')
   }
 
-  disableAutoResolution () {
+  disableAutoResolution (forbid = false) {
+    if (forbid === true) this.forbidAutoResolution = true
+
     this.autoResolution = false
     this.trigger('autoResolutionUpdate')
   }
 
+  isAutoResolutionForbidden () {
+    return this.forbidAutoResolution === true
+  }
+
   getCurrentVideoFile () {
     return this.currentVideoFile
   }
@@ -509,6 +516,8 @@ class PeerTubePlugin extends Plugin {
   }
 
   private fallbackToHttp (done?: Function, play = true) {
+    this.disableAutoResolution(true)
+
     this.flushVideoFile(this.currentVideoFile, true)
     this.torrent = null
 
@@ -555,7 +564,7 @@ class PeerTubePlugin extends Plugin {
     this.player.controlBar.on('mouseenter', () => disableInactivity())
     settingsDialog.on('mouseenter', () => disableInactivity())
     this.player.controlBar.on('mouseleave', () => enableInactivity())
-    settingsDialog.on('mouseleave', () => enableInactivity())
+    // settingsDialog.on('mouseleave', () => enableInactivity())
   }
 
   private pickAverageVideoFile () {
index d317a5efc971b6e0aa28bffbc32e0d17d249fea4..e300741738bb66fb217acc9fce2ca3058a0498dd 100644 (file)
@@ -12,6 +12,7 @@ class ResolutionMenuButton extends MenuButton {
     this.player = player
 
     player.peertube().on('videoFileUpdate', () => this.updateLabel())
+    player.peertube().on('autoResolutionUpdate', () => this.updateLabel())
   }
 
   createEl () {
index 3fe1d8f0fdbb5dba58a793d81509f846bf818614..0ab0f53b54b13109d45aa98de3f47fe3ae48a258 100644 (file)
@@ -19,6 +19,8 @@ class ResolutionMenuItem extends MenuItem {
   }
 
   handleClick (event) {
+    if (this.id === -1 && this.player_.peertube().isAutoResolutionForbidden()) return
+
     super.handleClick(event)
 
     // Auto resolution
@@ -32,6 +34,15 @@ class ResolutionMenuItem extends MenuItem {
   }
 
   updateSelection () {
+    // Check if auto resolution is forbidden or not
+    if (this.id === -1) {
+      if (this.player_.peertube().isAutoResolutionForbidden()) {
+        this.addClass('disabled')
+      } else {
+        this.removeClass('disabled')
+      }
+    }
+
     if (this.player_.peertube().isAutoResolutionOn()) {
       this.selected(this.id === -1)
       return
index f95123f52589e63028b22c61de4caef532388cf8..0c064c18256429196c49960c92422551047ece6e 100644 (file)
@@ -99,8 +99,11 @@ $setting-transition-easing: ease-out;
         transition: all $setting-transition-duration $setting-transition-easing;
 
         .vjs-menu-item {
+          font-size: 1em;
+          text-transform: initial;
 
           &:hover {
+            cursor: pointer;
             background-color: rgba(255, 255, 255, 0.2);
           }
 
@@ -111,14 +114,11 @@ $setting-transition-easing: ease-out;
           &:last-child {
             margin-bottom: 5px;
           }
-        }
 
-        li {
-          font-size: 1em;
-          text-transform: initial;
-
-          &:hover {
-            cursor: pointer;
+          &.disabled {
+            opacity: 0.5;
+            cursor: default !important;
+            background-color: inherit !important;
           }
         }
       }