]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/resolution-menu-item.ts
Improve first play
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / resolution-menu-item.ts
CommitLineData
c6352f2c
C
1import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
2
3const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem')
4class ResolutionMenuItem extends MenuItem {
5
6 constructor (player: videojs.Player, options) {
7 const currentResolutionId = player.peertube().getCurrentResolutionId()
8 options.selectable = true
9 options.selected = options.id === currentResolutionId
10
11 super(player, options)
12
13 this.label = options.label
14 this.id = options.id
15
16 player.peertube().on('videoFileUpdate', () => this.update())
17 }
18
19 handleClick (event) {
20 super.handleClick(event)
21
22 this.player_.peertube().updateResolution(this.id)
23 }
24
25 update () {
26 this.selected(this.player_.peertube().getCurrentResolutionId() === this.id)
27 }
28}
29MenuItem.registerComponent('ResolutionMenuItem', ResolutionMenuItem)
30
31export { ResolutionMenuItem }