aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/resolution-menu-button.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-11 11:52:34 +0100
committerChocobozzz <me@florianbigard.com>2019-02-11 11:52:34 +0100
commit88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch)
treeb242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /client/src/assets/player/resolution-menu-button.ts
parent53a94c7cfa8368da4cd248d65df8346905938f0c (diff)
parent9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff)
downloadPeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz
PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst
PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip
Merge branch 'develop' into pr/1217
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)