1 import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
2 import { saveTheaterInStore, getStoredTheater } from './peertube-player-local-storage'
4 const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
5 class TheaterButton extends Button {
7 private static readonly THEATER_MODE_CLASS = 'vjs-theater-enabled'
9 constructor (player: any, options: any) {
10 super(player, options)
12 const enabled = getStoredTheater()
13 if (enabled === true) {
14 this.player_.addClass(TheaterButton.THEATER_MODE_CLASS)
15 this.handleTheaterChange()
20 return `vjs-theater-control ${super.buildCSSClass()}`
23 handleTheaterChange () {
24 if (this.isTheaterEnabled()) {
25 this.controlText('Normal mode')
27 this.controlText('Theater mode')
30 saveTheaterInStore(this.isTheaterEnabled())
34 this.player_.toggleClass(TheaterButton.THEATER_MODE_CLASS)
36 this.handleTheaterChange()
39 private isTheaterEnabled () {
40 return this.player_.hasClass(TheaterButton.THEATER_MODE_CLASS)
44 TheaterButton.prototype.controlText_ = 'Theater mode'
46 TheaterButton.registerComponent('TheaterButton', TheaterButton)