29 lines
842 B
JavaScript
29 lines
842 B
JavaScript
// @flow
|
|
import type { Player } from './videojs';
|
|
import videojs from 'video.js';
|
|
|
|
class AutoplayNextButton extends videojs.getComponent('Button') {
|
|
constructor(player, options = {}, autoplay) {
|
|
super(player, options, autoplay);
|
|
this.addClass(autoplay ? 'vjs-button--autoplay-next--active' : 'vjs-button--autoplay-next');
|
|
this.controlText(autoplay ? 'Autoplay Next On' : 'Autoplay Next Off');
|
|
}
|
|
}
|
|
|
|
export function addAutoplayNextButton(player: Player, toggleAutoplayNext: () => void, autoplay: boolean) {
|
|
const controlBar = player.getChild('controlBar');
|
|
|
|
const autoplayButton = new AutoplayNextButton(
|
|
player,
|
|
{
|
|
name: 'AutoplayNextButton',
|
|
text: __('Autoplay Next'),
|
|
clickHandler: () => {
|
|
toggleAutoplayNext();
|
|
},
|
|
},
|
|
autoplay
|
|
);
|
|
|
|
controlBar.addChild(autoplayButton);
|
|
}
|