From c4082b8b4e3684baae0172e97297c936d7419f2c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 22 Jun 2018 15:06:33 +0200 Subject: Disable auto resolution on HTTP fallback --- client/src/assets/player/peertube-videojs-plugin.ts | 13 +++++++++++-- client/src/assets/player/resolution-menu-button.ts | 1 + client/src/assets/player/resolution-menu-item.ts | 11 +++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'client/src/assets/player') diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index fc07c35d6..208105d3c 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts @@ -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 () { diff --git a/client/src/assets/player/resolution-menu-button.ts b/client/src/assets/player/resolution-menu-button.ts index d317a5efc..e30074173 100644 --- a/client/src/assets/player/resolution-menu-button.ts +++ b/client/src/assets/player/resolution-menu-button.ts @@ -12,6 +12,7 @@ class ResolutionMenuButton extends MenuButton { this.player = player player.peertube().on('videoFileUpdate', () => this.updateLabel()) + player.peertube().on('autoResolutionUpdate', () => this.updateLabel()) } createEl () { diff --git a/client/src/assets/player/resolution-menu-item.ts b/client/src/assets/player/resolution-menu-item.ts index 3fe1d8f0f..0ab0f53b5 100644 --- a/client/src/assets/player/resolution-menu-item.ts +++ b/client/src/assets/player/resolution-menu-item.ts @@ -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 -- cgit v1.2.3