lbry-desktop/ui/component/viewers/videoViewer/internal/plugins/videojs-hls-quality-selector/ConcreteMenuItem.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

import videojs from 'video.js';
// Concrete classes
const VideoJsMenuItemClass = videojs.getComponent('MenuItem');
/**
* Extend vjs menu item class.
*/
export default class ConcreteMenuItem extends VideoJsMenuItemClass {
/**
* Menu item constructor.
*
* @param {Player} player - vjs player
* @param {Object} item - Item object
* @param {ConcreteButton} qualityButton - The containing button.
* @param {HlsQualitySelectorPlugin} plugin - This plugin instance.
*/
constructor(player, item, qualityButton, plugin) {
super(player, {
label: item.label,
selectable: true,
2021-02-18 19:45:39 +01:00
selected: item.selected || false,
});
this.item = item;
this.qualityButton = qualityButton;
this.plugin = plugin;
}
/**
* Click event for menu item.
*/
handleClick() {
// Reset other menu items selected status.
for (let i = 0; i < this.qualityButton.items.length; ++i) {
this.qualityButton.items[i].selected(false);
}
// Set this menu item to selected, and set quality.
this.plugin.setQuality(this.item.value);
this.selected(true);
}
}