GithubHelp home page GithubHelp logo

Comments (6)

mister-ben avatar mister-ben commented on May 30, 2024 1

The reason it didn't work is settingButton.createMenu() will create a new but detached menu DOM. It doesn't return or replace the original one. let settingMenu = settingButton.menu; should work in your original code.

from video.js.

welcome avatar welcome commented on May 30, 2024

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

from video.js.

amtins avatar amtins commented on May 30, 2024

@rudachenkoev what about something like?

function setupPlayer() {
  if (!this.$refs.videoPlayer) return false;
  this.player = videojs(this.$refs.videoPlayer, this.options, () => {
    let MenuItem = videojs.getComponent('MenuItem');
    let MenuButton = videojs.getComponent('MenuButton');

    MenuButton.prototype.createItems = function (
      options = this.options.scaledFiles
    ) {
      const items = [];

      for (let quality of options) {
        items.push(new MenuItem(this.player(), { label: quality.resolution }));
      }

      return items;
    };

    let settingButton = new MenuButton(this.player);
    settingButton.setIcon('cog');

    this.player.getChild('ControlBar').addChild(settingButton);
  });
}

from video.js.

rudachenkoev avatar rudachenkoev commented on May 30, 2024

@amtins thank you for your reply
your option worked for me, just with a few minor changes
perhaps this will also be useful for someone else

MenuButton.prototype.createItems = function (options = this.options.scaledFiles) { ... } => MenuButton.prototype.createItems = (options = this.options.scaledFiles) => { ... }

items.push(new MenuItem(this.player(), { label: quality.resolution })); => items.push(new MenuItem(this.player, { label: quality.resolution }));

from video.js.

rudachenkoev avatar rudachenkoev commented on May 30, 2024

@mister-ben yeah, it really works, thanks
perhaps you can give some more advice on the "selected" option in MenuItem
I want to highlight one of the options as active, but none of the following options helped me:

  1. qualityItem.selected(true)
  2. let qualityItem = new MenuItem(this.player, { label: quality.resolution, selected: true })

from video.js.

rudachenkoev avatar rudachenkoev commented on May 30, 2024

figured it out.
To make MenuItem with selectable option you need to add the option selectable: true - new MenuItem(this.player, { label: quality.resolution, selectable: true })
although there is nothing about it in the documentation

from video.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.