Extending progress control in video.js, duplicate progress bars

2.8k Views Asked by At

I'm having an issue when I extend the progressControl object it also clones the slider, so there is currently two. Am I wrong in trying to approach this by extending progressControl or should I go about creating the element a different way?

this.player = videojs("id", videojsOptions);
var thePlayer = this.player;

videojs.TrimVideo = videojs.ProgressControl.extend({
    init: function(player, options){
        videojs.ProgressControl.call(this, player, options);
    }
});

this.player.controlBar.progressControl.trimVideo = this.player.controlBar.progressControl.addChild(
    new videojs.TrimVideo(thePlayer, {
        el: videojs.Component.prototype.createEl(null, {
            className: 'vjs-trim-start-button vjs-menu-button',
            innerHTML: '<div style="">words and words</div>',
            role: 'button'
        })
    })
);

Mini progress control under new element

Link to Progress Control documentation

Have created a jsfiddle that replicates the behaviour

1

There are 1 best solutions below

0
On BEST ANSWER

When initialising a new progressControl it merges the children together, you have to explicitly set seekBar to false. So you would end up with something like

this.player.controlBar.progressControl.trimVideo = this.player.controlBar.progressControl.addChild(
    new videojs.TrimVideo(thePlayer, {
        el: videojs.Component.prototype.createEl(null, {
            className: 'vjs-trim-start-button vjs-menu-button',
            innerHTML: '<div style="">words and words</div>',
            role: 'button'
        }),
        seekBar: false, // either this
        children: {seekBar: false} // or this
    })
);