chrisboustead / videojs-hls-quality-selector

Adds a quality selector menu for HLS sources played in videojs. Requires `videojs-contrib-quality-levels` plugin.
MIT License
140 stars 103 forks source link

This plugin is not compatible with Video.js 8 #108

Open dangngocbinh opened 11 months ago

dangngocbinh commented 11 months ago

This plugin is not compatible with Video.js 8 due to changes in Video.js's component extension mechanism. To make it compatible, you should replace ConcreteButton and ConcreteMenuItem with the extend method as follows: const ButtonComponent = videojs.getComponent("MenuButton");

class ConcreteButton extends ButtonComponent { constructor(player, options) { super(player, options); }

createItems() { return []; }

createMenu() { var menu = new VideoJsMenuClass(this.player_, { menuButton: this });

this.hideThreshold_ = 0;

if (this.options_.title) {
  var titleEl = Dom.createEl("li", {
    className: "vjs-menu-title",
    innerHTML: toTitleCase(this.options_.title),
    tabIndex: -1,
  });
  var titleComponent = new VideoJsComponent(this.player_, {
    el: titleEl,
  });

  this.hideThreshold_ += 1;

  menu.addItem(titleComponent);
}

this.items = this.createItems();

if (this.items) {
  for (var i = 0; i < this.items.length; i++) {
    menu.addItem(this.items[i]);
  }
}

return menu;

} }

videojs.registerComponent("ConcreteButton", ConcreteButton);

const MenuComponent = videojs.getComponent("MenuItem"); class ConcreteMenuItem extends MenuComponent { constructor(player, item, qualityButton, plugin) { super(player, item); this.item = item; this.qualityButton = qualityButton; this.plugin = plugin; }

handleClick() { for (var i = 0; i < this.qualityButton.items.length; ++i) { this.qualityButton.items[i].selected(false); } this.plugin.setQuality(this.item.value); this.selected(true); } }

videojs.registerComponent("ConcreteMenuItem", ConcreteMenuItem);

aproni34f commented 9 months ago

@dangngocbinh I cannot make this work with videojs 8

can you update the demo here?

https://jsfiddle.net/873c2st0/1/

dangngocbinh commented 9 months ago

@aproni34f yes, i update demo at this link: https://jsfiddle.net/enu2jLd8/

PI3RRE01 commented 8 months ago

H, Bellow a fork that update videojs plugin template. It was tested with VJS 8.6.1 using standard JS file importation in html page.

https://github.com/PI3RRE01/videojs-hls-quality-selector

halilyucel commented 7 months ago

@dangngocbinh you are awesome man!

oliverphardman commented 7 months ago

Hi @PI3RRE01 please could you open a PR for this? Your fork works perfectly! Thanks.

backendskybr commented 6 months ago

H, Bellow a fork that update videojs plugin template. It was tested with VJS 8.6.1 using standard JS file importation in html page.

https://github.com/PI3RRE01/videojs-hls-quality-selector

Hi. how to use your library using npm? thanks

oliverphardman commented 5 months ago

Issue resolved in #109