aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/resolution-menu-button.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/resolution-menu-button.ts')
-rw-r--r--client/src/assets/player/resolution-menu-button.ts88
1 files changed, 0 insertions, 88 deletions
diff --git a/client/src/assets/player/resolution-menu-button.ts b/client/src/assets/player/resolution-menu-button.ts
deleted file mode 100644
index a3c1108ca..000000000
--- a/client/src/assets/player/resolution-menu-button.ts
+++ /dev/null
@@ -1,88 +0,0 @@
1// FIXME: something weird with our path definition in tsconfig and typings
2// @ts-ignore
3import { Player } from 'video.js'
4
5import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
6import { ResolutionMenuItem } from './resolution-menu-item'
7
8const Menu: VideoJSComponentInterface = videojsUntyped.getComponent('Menu')
9const MenuButton: VideoJSComponentInterface = videojsUntyped.getComponent('MenuButton')
10class ResolutionMenuButton extends MenuButton {
11 label: HTMLElement
12
13 constructor (player: Player, options: any) {
14 super(player, options)
15 this.player = player
16
17 player.peertube().on('videoFileUpdate', () => this.updateLabel())
18 player.peertube().on('autoResolutionUpdate', () => this.updateLabel())
19 }
20
21 createEl () {
22 const el = super.createEl()
23
24 this.labelEl_ = videojsUntyped.dom.createEl('div', {
25 className: 'vjs-resolution-value',
26 innerHTML: this.buildLabelHTML()
27 })
28
29 el.appendChild(this.labelEl_)
30
31 return el
32 }
33
34 updateARIAAttributes () {
35 this.el().setAttribute('aria-label', 'Quality')
36 }
37
38 createMenu () {
39 const menu = new Menu(this.player_)
40 for (const videoFile of this.player_.peertube().videoFiles) {
41 let label = videoFile.resolution.label
42 if (videoFile.fps && videoFile.fps >= 50) {
43 label += videoFile.fps
44 }
45
46 menu.addChild(new ResolutionMenuItem(
47 this.player_,
48 {
49 id: videoFile.resolution.id,
50 label,
51 src: videoFile.magnetUri
52 })
53 )
54 }
55
56 menu.addChild(new ResolutionMenuItem(
57 this.player_,
58 {
59 id: -1,
60 label: this.player_.localize('Auto'),
61 src: null
62 }
63 ))
64
65 return menu
66 }
67
68 updateLabel () {
69 if (!this.labelEl_) return
70
71 this.labelEl_.innerHTML = this.buildLabelHTML()
72 }
73
74 buildCSSClass () {
75 return super.buildCSSClass() + ' vjs-resolution-button'
76 }
77
78 buildWrapperCSSClass () {
79 return 'vjs-resolution-control ' + super.buildWrapperCSSClass()
80 }
81
82 private buildLabelHTML () {
83 return this.player_.peertube().getCurrentResolutionLabel()
84 }
85}
86ResolutionMenuButton.prototype.controlText_ = 'Quality'
87
88MenuButton.registerComponent('ResolutionMenuButton', ResolutionMenuButton)