Adding Custom Video.js Control Bar buttons

后端 未结 3 1301
北荒
北荒 2021-02-06 06:33

I\'ve been working on video.js for like a day so I\'m a real newbie when it comes to this stuff Today I just wanted to add a button that will switch between two videos. I did it

3条回答
  •  忘了有多久
    2021-02-06 07:09

    The undefined is coming from the fact that MyButton is not a vjs.Component. The documentation around this is a little unclear and it took me a while to understand what is going on.

    The documentation states that the first argument is the "class name or instance of a child to add" - it's referring to a JavaScript class rather than a CSS class. The correct way to add a button is as follows:

    var myButton = video.controlBar.addChild('button', {
        text: "Press me",
        // other options
      });
    
    myButton.addClass("html-classname");
    

    This will add the following to your controlbar:

提交回复
热议问题