X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fresolution-menu-item.ts;h=0ab0f53b54b13109d45aa98de3f47fe3ae48a258;hb=0491173a61aed66205c017e0d7e0503ea316c144;hp=8ad834c59c6b6432474a769a018cb5649e79fada;hpb=b891f9bc612217b5b6f08a886c7d12eca260b9c8;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/resolution-menu-item.ts b/client/src/assets/player/resolution-menu-item.ts index 8ad834c59..0ab0f53b5 100644 --- a/client/src/assets/player/resolution-menu-item.ts +++ b/client/src/assets/player/resolution-menu-item.ts @@ -1,3 +1,4 @@ +import * as videojs from 'video.js' import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem') @@ -14,17 +15,49 @@ class ResolutionMenuItem extends MenuItem { this.id = options.id player.peertube().on('videoFileUpdate', () => this.updateSelection()) + player.peertube().on('autoResolutionUpdate', () => this.updateSelection()) } handleClick (event) { + if (this.id === -1 && this.player_.peertube().isAutoResolutionForbidden()) return + 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 () { + // 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 + } + 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)