Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dangngocbinh opened this issue Oct 18, 2023 · 7 comments
Open

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

dangngocbinh opened this issue Oct 18, 2023 · 7 comments

Comments

@dangngocbinh
Copy link

dangngocbinh commented Oct 18, 2023

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
Copy link

aproni34f commented Nov 28, 2023

@dangngocbinh I cannot make this work with videojs 8

can you update the demo here?

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

@dangngocbinh
Copy link
Author

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

@PI3RRE01
Copy link

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
Copy link

@dangngocbinh you are awesome man!

@oliverphardman
Copy link

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

@backendskybr
Copy link

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
Copy link

Issue resolved in #109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants