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