1 import * as videojs from 'video.js'
2 import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
4 const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem')
5 class ResolutionMenuItem extends MenuItem {
7 constructor (player: videojs.Player, options) {
8 const currentResolutionId = player.peertube().getCurrentResolutionId()
9 options.selectable = true
10 options.selected = options.id === currentResolutionId
12 super(player, options)
14 this.label = options.label
17 player.peertube().on('videoFileUpdate', () => this.updateSelection())
18 player.peertube().on('autoResolutionUpdate', () => this.updateSelection())
22 super.handleClick(event)
26 this.player_.peertube().enableAutoResolution()
30 this.player_.peertube().disableAutoResolution()
31 this.player_.peertube().updateResolution(this.id)
35 if (this.player_.peertube().isAutoResolutionOn()) {
36 this.selected(this.id === -1)
40 this.selected(this.player_.peertube().getCurrentResolutionId() === this.id)
45 return this.label + ' <small>' + this.player_.peertube().getCurrentResolutionLabel() + '</small>'
51 MenuItem.registerComponent('ResolutionMenuItem', ResolutionMenuItem)
53 export { ResolutionMenuItem }