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
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: