blob: 712e7119260bc818e689e5d456a7aaf934effe15 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
import * as videojs from 'video.js'
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
import { ResolutionMenuItem } from './resolution-menu-item'
const Menu: VideoJSComponentInterface = videojsUntyped.getComponent('Menu')
const MenuButton: VideoJSComponentInterface = videojsUntyped.getComponent('MenuButton')
class ResolutionMenuButton extends MenuButton {
label: HTMLElement
constructor (player: videojs.Player, options) {
options.label = 'Quality'
super(player, options)
this.controlText_ = 'Quality'
this.player = player
player.peertube().on('videoFileUpdate', () => this.updateLabel())
}
createEl () {
const el = super.createEl()
this.labelEl_ = videojsUntyped.dom.createEl('div', {
className: 'vjs-resolution-value',
innerHTML: this.player_.peertube().getCurrentResolutionLabel()
})
el.appendChild(this.labelEl_)
return el
}
updateARIAAttributes () {
this.el().setAttribute('aria-label', 'Quality')
}
createMenu () {
const menu = new Menu(this.player_)
for (const videoFile of this.player_.peertube().videoFiles) {
menu.addChild(new ResolutionMenuItem(
this.player_,
{
id: videoFile.resolution.id,
label: videoFile.resolution.label,
src: videoFile.magnetUri
})
)
}
return menu
}
updateLabel () {
if (!this.labelEl_) return
this.labelEl_.innerHTML = this.player_.peertube().getCurrentResolutionLabel()
}
buildCSSClass () {
return super.buildCSSClass() + ' vjs-resolution-button'
}
buildWrapperCSSClass () {
return 'vjs-resolution-control ' + super.buildWrapperCSSClass()
}
}
MenuButton.registerComponent('ResolutionMenuButton', ResolutionMenuButton)
|