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())
+ player.peertube().on('autoResolutionUpdate', () => this.updateLabel())
}
createEl () {
this.labelEl_ = videojsUntyped.dom.createEl('div', {
className: 'vjs-resolution-value',
- innerHTML: this.player_.peertube().getCurrentResolutionLabel()
+ innerHTML: this.buildLabelHTML()
})
el.appendChild(this.labelEl_)
createMenu () {
const menu = new Menu(this.player_)
for (const videoFile of this.player_.peertube().videoFiles) {
+ let label = videoFile.resolution.label
+ if (videoFile.fps && videoFile.fps >= 50) {
+ label += videoFile.fps
+ }
+
menu.addChild(new ResolutionMenuItem(
this.player_,
{
id: videoFile.resolution.id,
- label: videoFile.resolution.label,
+ label,
src: videoFile.magnetUri
})
)
}
+ menu.addChild(new ResolutionMenuItem(
+ this.player_,
+ {
+ id: -1,
+ label: this.player_.localize('Auto'),
+ src: null
+ }
+ ))
+
return menu
}
updateLabel () {
if (!this.labelEl_) return
- this.labelEl_.innerHTML = this.player_.peertube().getCurrentResolutionLabel()
+ this.labelEl_.innerHTML = this.buildLabelHTML()
}
buildCSSClass () {
buildWrapperCSSClass () {
return 'vjs-resolution-control ' + super.buildWrapperCSSClass()
}
+
+ private buildLabelHTML () {
+ return this.player_.peertube().getCurrentResolutionLabel()
+ }
}
+ResolutionMenuButton.prototype.controlText_ = 'Quality'
+
MenuButton.registerComponent('ResolutionMenuButton', ResolutionMenuButton)