From a8462c8e3a61f4f7314fe18c0c10cc2946c254d1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 5 Apr 2018 16:15:51 +0200 Subject: Automatic resolution according to user bandwidth V1 --- client/src/assets/player/resolution-menu-item.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'client/src/assets/player/resolution-menu-item.ts') diff --git a/client/src/assets/player/resolution-menu-item.ts b/client/src/assets/player/resolution-menu-item.ts index 8ad834c59..4b1ed0642 100644 --- a/client/src/assets/player/resolution-menu-item.ts +++ b/client/src/assets/player/resolution-menu-item.ts @@ -14,17 +14,38 @@ class ResolutionMenuItem extends MenuItem { this.id = options.id player.peertube().on('videoFileUpdate', () => this.updateSelection()) + player.peertube().on('autoResolutionUpdate', () => this.updateSelection()) } handleClick (event) { super.handleClick(event) + // Auto resolution + if (this.id === -1) { + this.player_.peertube().enableAutoResolution() + return + } + + this.player_.peertube().disableAutoResolution() this.player_.peertube().updateResolution(this.id) } updateSelection () { + if (this.player_.peertube().isAutoResolutionOn()) { + this.selected(this.id === -1) + return + } + this.selected(this.player_.peertube().getCurrentResolutionId() === this.id) } + + getLabel () { + if (this.id === -1) { + return this.label + ' ' + this.player_.peertube().getCurrentResolutionLabel() + '' + } + + return this.label + } } MenuItem.registerComponent('ResolutionMenuItem', ResolutionMenuItem) -- cgit v1.2.3