Adding Custom Video.js Control Bar buttons

后端 未结 3 1335
北荒
北荒 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:20

    Starting with v5:

    var videoJsButtonClass = videojs.getComponent('Button');
    var concreteButtonClass = videojs.extend(videoJsButtonClass, {
    
      // The `init()` method will also work for constructor logic here, but it is 
      // deprecated. If you provide an `init()` method, it will override the
      // `constructor()` method!
      constructor: function() {
        videoJsButtonClass.call(this, videojsInstance);
      }, // notice the comma
    
      handleClick: function(){
        // Do your stuff
      }
    });
    
    var concreteButtonInstance = videojsInstance.controlBar.addChild(new concreteButtonClass());
        concreteButtonInstance.addClass("vjs-" + name);
    

    PROFIT!

提交回复
热议问题