aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/shared/control-bar
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/shared/control-bar')
-rw-r--r--client/src/assets/player/shared/control-bar/index.ts1
-rw-r--r--client/src/assets/player/shared/control-bar/next-previous-video-button.ts25
-rw-r--r--client/src/assets/player/shared/control-bar/p2p-info-button.ts103
-rw-r--r--client/src/assets/player/shared/control-bar/peertube-link-button.ts47
-rw-r--r--client/src/assets/player/shared/control-bar/peertube-live-display.ts8
-rw-r--r--client/src/assets/player/shared/control-bar/peertube-load-progress-bar.ts33
-rw-r--r--client/src/assets/player/shared/control-bar/storyboard-plugin.ts17
-rw-r--r--client/src/assets/player/shared/control-bar/theater-button.ts17
8 files changed, 126 insertions, 125 deletions
diff --git a/client/src/assets/player/shared/control-bar/index.ts b/client/src/assets/player/shared/control-bar/index.ts
index 24877c267..9307027f6 100644
--- a/client/src/assets/player/shared/control-bar/index.ts
+++ b/client/src/assets/player/shared/control-bar/index.ts
@@ -2,6 +2,5 @@ export * from './next-previous-video-button'
2export * from './p2p-info-button' 2export * from './p2p-info-button'
3export * from './peertube-link-button' 3export * from './peertube-link-button'
4export * from './peertube-live-display' 4export * from './peertube-live-display'
5export * from './peertube-load-progress-bar'
6export * from './storyboard-plugin' 5export * from './storyboard-plugin'
7export * from './theater-button' 6export * from './theater-button'
diff --git a/client/src/assets/player/shared/control-bar/next-previous-video-button.ts b/client/src/assets/player/shared/control-bar/next-previous-video-button.ts
index b7b986806..18a107f52 100644
--- a/client/src/assets/player/shared/control-bar/next-previous-video-button.ts
+++ b/client/src/assets/player/shared/control-bar/next-previous-video-button.ts
@@ -4,14 +4,18 @@ import { NextPreviousVideoButtonOptions } from '../../types'
4const Button = videojs.getComponent('Button') 4const Button = videojs.getComponent('Button')
5 5
6class NextPreviousVideoButton extends Button { 6class NextPreviousVideoButton extends Button {
7 private readonly nextPreviousVideoButtonOptions: NextPreviousVideoButtonOptions 7 options_: NextPreviousVideoButtonOptions & videojs.ComponentOptions
8 8
9 constructor (player: videojs.Player, options?: NextPreviousVideoButtonOptions) { 9 constructor (player: videojs.Player, options?: NextPreviousVideoButtonOptions & videojs.ComponentOptions) {
10 super(player, options as any) 10 super(player, options)
11 11
12 this.nextPreviousVideoButtonOptions = options 12 this.player().on('video-change', () => {
13 this.updateDisabled()
14 this.updateShowing()
15 })
13 16
14 this.update() 17 this.updateDisabled()
18 this.updateShowing()
15 } 19 }
16 20
17 createEl () { 21 createEl () {
@@ -35,15 +39,20 @@ class NextPreviousVideoButton extends Button {
35 } 39 }
36 40
37 handleClick () { 41 handleClick () {
38 this.nextPreviousVideoButtonOptions.handler() 42 this.options_.handler()
39 } 43 }
40 44
41 update () { 45 updateDisabled () {
42 const disabled = this.nextPreviousVideoButtonOptions.isDisabled() 46 const disabled = this.options_.isDisabled()
43 47
44 if (disabled) this.addClass('vjs-disabled') 48 if (disabled) this.addClass('vjs-disabled')
45 else this.removeClass('vjs-disabled') 49 else this.removeClass('vjs-disabled')
46 } 50 }
51
52 updateShowing () {
53 if (this.options_.isDisplayed()) this.show()
54 else this.hide()
55 }
47} 56}
48 57
49videojs.registerComponent('NextVideoButton', NextPreviousVideoButton) 58videojs.registerComponent('NextVideoButton', NextPreviousVideoButton)
diff --git a/client/src/assets/player/shared/control-bar/p2p-info-button.ts b/client/src/assets/player/shared/control-bar/p2p-info-button.ts
index 1979654ad..4177b3280 100644
--- a/client/src/assets/player/shared/control-bar/p2p-info-button.ts
+++ b/client/src/assets/player/shared/control-bar/p2p-info-button.ts
@@ -1,71 +1,44 @@
1import videojs from 'video.js' 1import videojs from 'video.js'
2import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../../types' 2import { PlayerNetworkInfo } from '../../types'
3import { bytes } from '../common' 3import { bytes } from '../common'
4 4
5const Button = videojs.getComponent('Button') 5const Button = videojs.getComponent('Button')
6class P2pInfoButton extends Button { 6class P2PInfoButton extends Button {
7 7 el_: HTMLElement
8 constructor (player: videojs.Player, options?: PeerTubeP2PInfoButtonOptions) {
9 super(player, options as any)
10 }
11 8
12 createEl () { 9 createEl () {
13 const div = videojs.dom.createEl('div', { 10 const div = videojs.dom.createEl('div', { className: 'vjs-peertube' })
14 className: 'vjs-peertube' 11 const subDivP2P = videojs.dom.createEl('div', {
15 })
16 const subDivWebtorrent = videojs.dom.createEl('div', {
17 className: 'vjs-peertube-hidden' // Hide the stats before we get the info 12 className: 'vjs-peertube-hidden' // Hide the stats before we get the info
18 }) as HTMLDivElement 13 }) as HTMLDivElement
19 div.appendChild(subDivWebtorrent) 14 div.appendChild(subDivP2P)
20 15
21 // Stop here if P2P is not enabled 16 const downloadIcon = videojs.dom.createEl('span', { className: 'icon icon-download' })
22 const p2pEnabled = (this.options_ as PeerTubeP2PInfoButtonOptions).p2pEnabled 17 subDivP2P.appendChild(downloadIcon)
23 if (!p2pEnabled) return div as HTMLButtonElement
24 18
25 const downloadIcon = videojs.dom.createEl('span', { 19 const downloadSpeedText = videojs.dom.createEl('span', { className: 'download-speed-text' })
26 className: 'icon icon-download' 20 const downloadSpeedNumber = videojs.dom.createEl('span', { className: 'download-speed-number' })
27 })
28 subDivWebtorrent.appendChild(downloadIcon)
29
30 const downloadSpeedText = videojs.dom.createEl('span', {
31 className: 'download-speed-text'
32 })
33 const downloadSpeedNumber = videojs.dom.createEl('span', {
34 className: 'download-speed-number'
35 })
36 const downloadSpeedUnit = videojs.dom.createEl('span') 21 const downloadSpeedUnit = videojs.dom.createEl('span')
37 downloadSpeedText.appendChild(downloadSpeedNumber) 22 downloadSpeedText.appendChild(downloadSpeedNumber)
38 downloadSpeedText.appendChild(downloadSpeedUnit) 23 downloadSpeedText.appendChild(downloadSpeedUnit)
39 subDivWebtorrent.appendChild(downloadSpeedText) 24 subDivP2P.appendChild(downloadSpeedText)
40 25
41 const uploadIcon = videojs.dom.createEl('span', { 26 const uploadIcon = videojs.dom.createEl('span', { className: 'icon icon-upload' })
42 className: 'icon icon-upload' 27 subDivP2P.appendChild(uploadIcon)
43 })
44 subDivWebtorrent.appendChild(uploadIcon)
45 28
46 const uploadSpeedText = videojs.dom.createEl('span', { 29 const uploadSpeedText = videojs.dom.createEl('span', { className: 'upload-speed-text' })
47 className: 'upload-speed-text' 30 const uploadSpeedNumber = videojs.dom.createEl('span', { className: 'upload-speed-number' })
48 })
49 const uploadSpeedNumber = videojs.dom.createEl('span', {
50 className: 'upload-speed-number'
51 })
52 const uploadSpeedUnit = videojs.dom.createEl('span') 31 const uploadSpeedUnit = videojs.dom.createEl('span')
53 uploadSpeedText.appendChild(uploadSpeedNumber) 32 uploadSpeedText.appendChild(uploadSpeedNumber)
54 uploadSpeedText.appendChild(uploadSpeedUnit) 33 uploadSpeedText.appendChild(uploadSpeedUnit)
55 subDivWebtorrent.appendChild(uploadSpeedText) 34 subDivP2P.appendChild(uploadSpeedText)
56 35
57 const peersText = videojs.dom.createEl('span', { 36 const peersText = videojs.dom.createEl('span', { className: 'peers-text' })
58 className: 'peers-text' 37 const peersNumber = videojs.dom.createEl('span', { className: 'peers-number' })
59 }) 38 subDivP2P.appendChild(peersNumber)
60 const peersNumber = videojs.dom.createEl('span', { 39 subDivP2P.appendChild(peersText)
61 className: 'peers-number'
62 })
63 subDivWebtorrent.appendChild(peersNumber)
64 subDivWebtorrent.appendChild(peersText)
65 40
66 const subDivHttp = videojs.dom.createEl('div', { 41 const subDivHttp = videojs.dom.createEl('div', { className: 'vjs-peertube-hidden' }) as HTMLElement
67 className: 'vjs-peertube-hidden'
68 })
69 const subDivHttpText = videojs.dom.createEl('span', { 42 const subDivHttpText = videojs.dom.createEl('span', {
70 className: 'http-fallback', 43 className: 'http-fallback',
71 textContent: 'HTTP' 44 textContent: 'HTTP'
@@ -74,14 +47,9 @@ class P2pInfoButton extends Button {
74 subDivHttp.appendChild(subDivHttpText) 47 subDivHttp.appendChild(subDivHttpText)
75 div.appendChild(subDivHttp) 48 div.appendChild(subDivHttp)
76 49
77 this.player_.on('p2pInfo', (event: any, data: PlayerNetworkInfo) => { 50 this.player_.on('p2p-info', (_event: any, data: PlayerNetworkInfo) => {
78 // We are in HTTP fallback 51 subDivP2P.className = 'vjs-peertube-displayed'
79 if (!data) { 52 subDivHttp.className = 'vjs-peertube-hidden'
80 subDivHttp.className = 'vjs-peertube-displayed'
81 subDivWebtorrent.className = 'vjs-peertube-hidden'
82
83 return
84 }
85 53
86 const p2pStats = data.p2p 54 const p2pStats = data.p2p
87 const httpStats = data.http 55 const httpStats = data.http
@@ -92,17 +60,17 @@ class P2pInfoButton extends Button {
92 const totalUploaded = bytes(p2pStats.uploaded) 60 const totalUploaded = bytes(p2pStats.uploaded)
93 const numPeers = p2pStats.numPeers 61 const numPeers = p2pStats.numPeers
94 62
95 subDivWebtorrent.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n' 63 subDivP2P.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n'
96 64
97 if (data.source === 'p2p-media-loader') { 65 if (data.source === 'p2p-media-loader') {
98 const downloadedFromServer = bytes(httpStats.downloaded).join(' ') 66 const downloadedFromServer = bytes(httpStats.downloaded).join(' ')
99 const downloadedFromPeers = bytes(p2pStats.downloaded).join(' ') 67 const downloadedFromPeers = bytes(p2pStats.downloaded).join(' ')
100 68
101 subDivWebtorrent.title += 69 subDivP2P.title +=
102 ' * ' + this.player().localize('From servers: ') + downloadedFromServer + '\n' + 70 ' * ' + this.player().localize('From servers: ') + downloadedFromServer + '\n' +
103 ' * ' + this.player().localize('From peers: ') + downloadedFromPeers + '\n' 71 ' * ' + this.player().localize('From peers: ') + downloadedFromPeers + '\n'
104 } 72 }
105 subDivWebtorrent.title += this.player().localize('Total uploaded: ') + totalUploaded.join(' ') 73 subDivP2P.title += this.player().localize('Total uploaded: ') + totalUploaded.join(' ')
106 74
107 downloadSpeedNumber.textContent = downloadSpeed[0] 75 downloadSpeedNumber.textContent = downloadSpeed[0]
108 downloadSpeedUnit.textContent = ' ' + downloadSpeed[1] 76 downloadSpeedUnit.textContent = ' ' + downloadSpeed[1]
@@ -114,11 +82,24 @@ class P2pInfoButton extends Button {
114 peersText.textContent = ' ' + (numPeers > 1 ? this.player().localize('peers') : this.player_.localize('peer')) 82 peersText.textContent = ' ' + (numPeers > 1 ? this.player().localize('peers') : this.player_.localize('peer'))
115 83
116 subDivHttp.className = 'vjs-peertube-hidden' 84 subDivHttp.className = 'vjs-peertube-hidden'
117 subDivWebtorrent.className = 'vjs-peertube-displayed' 85 subDivP2P.className = 'vjs-peertube-displayed'
86 })
87
88 this.player_.on('http-info', (_event, data: PlayerNetworkInfo) => {
89 // We are in HTTP fallback
90 subDivHttp.className = 'vjs-peertube-displayed'
91 subDivP2P.className = 'vjs-peertube-hidden'
92
93 subDivHttp.title = this.player().localize('Total downloaded: ') + bytes(data.http.downloaded).join(' ')
94 })
95
96 this.player_.on('video-change', () => {
97 subDivP2P.className = 'vjs-peertube-hidden'
98 subDivHttp.className = 'vjs-peertube-hidden'
118 }) 99 })
119 100
120 return div as HTMLButtonElement 101 return div as HTMLButtonElement
121 } 102 }
122} 103}
123 104
124videojs.registerComponent('P2PInfoButton', P2pInfoButton) 105videojs.registerComponent('P2PInfoButton', P2PInfoButton)
diff --git a/client/src/assets/player/shared/control-bar/peertube-link-button.ts b/client/src/assets/player/shared/control-bar/peertube-link-button.ts
index 45d7ac42f..8242b9cea 100644
--- a/client/src/assets/player/shared/control-bar/peertube-link-button.ts
+++ b/client/src/assets/player/shared/control-bar/peertube-link-button.ts
@@ -3,37 +3,58 @@ import { buildVideoLink, decorateVideoLink } from '@shared/core-utils'
3import { PeerTubeLinkButtonOptions } from '../../types' 3import { PeerTubeLinkButtonOptions } from '../../types'
4 4
5const Component = videojs.getComponent('Component') 5const Component = videojs.getComponent('Component')
6
6class PeerTubeLinkButton extends Component { 7class PeerTubeLinkButton extends Component {
8 private mouseEnterHandler: () => void
9 private clickHandler: () => void
7 10
8 constructor (player: videojs.Player, options?: PeerTubeLinkButtonOptions) { 11 options_: PeerTubeLinkButtonOptions & videojs.ComponentOptions
9 super(player, options as any)
10 }
11 12
12 createEl () { 13 constructor (player: videojs.Player, options?: PeerTubeLinkButtonOptions & videojs.ComponentOptions) {
13 return this.buildElement() 14 super(player, options)
15
16 this.updateShowing()
17 this.player().on('video-change', () => this.updateShowing())
14 } 18 }
15 19
16 updateHref () { 20 dispose () {
17 this.el().setAttribute('href', this.buildLink()) 21 if (this.el()) return
22
23 this.el().removeEventListener('mouseenter', this.mouseEnterHandler)
24 this.el().removeEventListener('click', this.clickHandler)
25
26 super.dispose()
18 } 27 }
19 28
20 private buildElement () { 29 createEl () {
21 const el = videojs.dom.createEl('a', { 30 const el = videojs.dom.createEl('a', {
22 href: this.buildLink(), 31 href: this.buildLink(),
23 innerHTML: (this.options_ as PeerTubeLinkButtonOptions).instanceName, 32 innerHTML: this.options_.instanceName,
24 title: this.player().localize('Video page (new window)'), 33 title: this.player().localize('Video page (new window)'),
25 className: 'vjs-peertube-link', 34 className: 'vjs-peertube-link',
26 target: '_blank' 35 target: '_blank'
27 }) 36 })
28 37
29 el.addEventListener('mouseenter', () => this.updateHref()) 38 this.mouseEnterHandler = () => this.updateHref()
30 el.addEventListener('click', () => this.player().pause()) 39 this.clickHandler = () => this.player().pause()
40
41 el.addEventListener('mouseenter', this.mouseEnterHandler)
42 el.addEventListener('click', this.clickHandler)
43
44 return el
45 }
46
47 updateShowing () {
48 if (this.options_.isDisplayed()) this.show()
49 else this.hide()
50 }
31 51
32 return el as HTMLButtonElement 52 updateHref () {
53 this.el().setAttribute('href', this.buildLink())
33 } 54 }
34 55
35 private buildLink () { 56 private buildLink () {
36 const url = buildVideoLink({ shortUUID: (this.options_ as PeerTubeLinkButtonOptions).shortUUID }) 57 const url = buildVideoLink({ shortUUID: this.options_.shortUUID() })
37 58
38 return decorateVideoLink({ url, startTime: this.player().currentTime() }) 59 return decorateVideoLink({ url, startTime: this.player().currentTime() })
39 } 60 }
diff --git a/client/src/assets/player/shared/control-bar/peertube-live-display.ts b/client/src/assets/player/shared/control-bar/peertube-live-display.ts
index 649eb0b00..f9f6bf12f 100644
--- a/client/src/assets/player/shared/control-bar/peertube-live-display.ts
+++ b/client/src/assets/player/shared/control-bar/peertube-live-display.ts
@@ -13,7 +13,6 @@ class PeerTubeLiveDisplay extends ClickableComponent {
13 13
14 this.interval = this.setInterval(() => this.updateClass(), 1000) 14 this.interval = this.setInterval(() => this.updateClass(), 1000)
15 15
16 this.show()
17 this.updateSync(true) 16 this.updateSync(true)
18 } 17 }
19 18
@@ -30,7 +29,7 @@ class PeerTubeLiveDisplay extends ClickableComponent {
30 29
31 createEl () { 30 createEl () {
32 const el = super.createEl('div', { 31 const el = super.createEl('div', {
33 className: 'vjs-live-control vjs-control' 32 className: 'vjs-pt-live-control vjs-control'
34 }) 33 })
35 34
36 this.contentEl_ = videojs.dom.createEl('div', { 35 this.contentEl_ = videojs.dom.createEl('div', {
@@ -83,10 +82,9 @@ class PeerTubeLiveDisplay extends ClickableComponent {
83 } 82 }
84 83
85 private getHLSJS () { 84 private getHLSJS () {
86 const p2pMediaLoader = this.player()?.p2pMediaLoader 85 if (!this.player()?.usingPlugin('p2pMediaLoader')) return
87 if (!p2pMediaLoader) return undefined
88 86
89 return p2pMediaLoader().getHLSJS() 87 return this.player().p2pMediaLoader().getHLSJS()
90 } 88 }
91} 89}
92 90
diff --git a/client/src/assets/player/shared/control-bar/peertube-load-progress-bar.ts b/client/src/assets/player/shared/control-bar/peertube-load-progress-bar.ts
deleted file mode 100644
index 623e70eb2..000000000
--- a/client/src/assets/player/shared/control-bar/peertube-load-progress-bar.ts
+++ /dev/null
@@ -1,33 +0,0 @@
1import videojs from 'video.js'
2
3const Component = videojs.getComponent('Component')
4
5class PeerTubeLoadProgressBar extends Component {
6
7 constructor (player: videojs.Player, options?: videojs.ComponentOptions) {
8 super(player, options)
9
10 this.on(player, 'progress', this.update)
11 }
12
13 createEl () {
14 return super.createEl('div', {
15 className: 'vjs-load-progress',
16 innerHTML: `<span class="vjs-control-text"><span>${this.localize('Loaded')}</span>: 0%</span>`
17 })
18 }
19
20 dispose () {
21 super.dispose()
22 }
23
24 update () {
25 const torrent = this.player().webtorrent().getTorrent()
26 if (!torrent) return
27
28 (this.el() as HTMLElement).style.width = (torrent.progress * 100) + '%'
29 }
30
31}
32
33Component.registerComponent('PeerTubeLoadProgressBar', PeerTubeLoadProgressBar)
diff --git a/client/src/assets/player/shared/control-bar/storyboard-plugin.ts b/client/src/assets/player/shared/control-bar/storyboard-plugin.ts
index 81ab60842..80c69b5f2 100644
--- a/client/src/assets/player/shared/control-bar/storyboard-plugin.ts
+++ b/client/src/assets/player/shared/control-bar/storyboard-plugin.ts
@@ -24,6 +24,8 @@ class StoryboardPlugin extends Plugin {
24 24
25 private readonly boundedHijackMouseTooltip: typeof StoryboardPlugin.prototype.hijackMouseTooltip 25 private readonly boundedHijackMouseTooltip: typeof StoryboardPlugin.prototype.hijackMouseTooltip
26 26
27 private onReadyOrLoadstartHandler: (event: { type: 'ready' }) => void
28
27 constructor (player: videojs.Player, options: videojs.ComponentOptions & StoryboardOptions) { 29 constructor (player: videojs.Player, options: videojs.ComponentOptions & StoryboardOptions) {
28 super(player, options) 30 super(player, options)
29 31
@@ -54,7 +56,7 @@ class StoryboardPlugin extends Plugin {
54 this.spritePlaceholder = videojs.dom.createEl('div', { className: 'vjs-storyboard-sprite-placeholder' }) as HTMLElement 56 this.spritePlaceholder = videojs.dom.createEl('div', { className: 'vjs-storyboard-sprite-placeholder' }) as HTMLElement
55 this.seekBar?.el()?.appendChild(this.spritePlaceholder) 57 this.seekBar?.el()?.appendChild(this.spritePlaceholder)
56 58
57 this.player.on([ 'ready', 'loadstart' ], event => { 59 this.onReadyOrLoadstartHandler = event => {
58 if (event.type !== 'ready') { 60 if (event.type !== 'ready') {
59 const spriteSource = this.player.currentSources().find(source => { 61 const spriteSource = this.player.currentSources().find(source => {
60 return Object.prototype.hasOwnProperty.call(source, 'storyboard') 62 return Object.prototype.hasOwnProperty.call(source, 'storyboard')
@@ -72,7 +74,18 @@ class StoryboardPlugin extends Plugin {
72 this.cached = !!this.sprites[this.url] 74 this.cached = !!this.sprites[this.url]
73 75
74 this.load() 76 this.load()
75 }) 77 }
78
79 this.player.on([ 'ready', 'loadstart' ], this.onReadyOrLoadstartHandler)
80 }
81
82 dispose () {
83 if (this.onReadyOrLoadstartHandler) this.player.off([ 'ready', 'loadstart' ], this.onReadyOrLoadstartHandler)
84 if (this.progress) this.progress.off([ 'mousemove', 'touchmove' ], this.boundedHijackMouseTooltip)
85
86 this.seekBar?.el()?.removeChild(this.spritePlaceholder)
87
88 super.dispose()
76 } 89 }
77 90
78 private load () { 91 private load () {
diff --git a/client/src/assets/player/shared/control-bar/theater-button.ts b/client/src/assets/player/shared/control-bar/theater-button.ts
index 56c349d6b..a5feb56ee 100644
--- a/client/src/assets/player/shared/control-bar/theater-button.ts
+++ b/client/src/assets/player/shared/control-bar/theater-button.ts
@@ -1,14 +1,19 @@
1import videojs from 'video.js' 1import videojs from 'video.js'
2import { getStoredTheater, saveTheaterInStore } from '../../peertube-player-local-storage' 2import { getStoredTheater, saveTheaterInStore } from '../../peertube-player-local-storage'
3import { TheaterButtonOptions } from '../../types'
3 4
4const Button = videojs.getComponent('Button') 5const Button = videojs.getComponent('Button')
5class TheaterButton extends Button { 6class TheaterButton extends Button {
6 7
7 private static readonly THEATER_MODE_CLASS = 'vjs-theater-enabled' 8 private static readonly THEATER_MODE_CLASS = 'vjs-theater-enabled'
8 9
9 constructor (player: videojs.Player, options: videojs.ComponentOptions) { 10 private theaterButtonOptions: TheaterButtonOptions
11
12 constructor (player: videojs.Player, options: TheaterButtonOptions & videojs.ComponentOptions) {
10 super(player, options) 13 super(player, options)
11 14
15 this.theaterButtonOptions = options
16
12 const enabled = getStoredTheater() 17 const enabled = getStoredTheater()
13 if (enabled === true) { 18 if (enabled === true) {
14 this.player().addClass(TheaterButton.THEATER_MODE_CLASS) 19 this.player().addClass(TheaterButton.THEATER_MODE_CLASS)
@@ -19,6 +24,9 @@ class TheaterButton extends Button {
19 this.controlText('Theater mode') 24 this.controlText('Theater mode')
20 25
21 this.player().theaterEnabled = enabled 26 this.player().theaterEnabled = enabled
27
28 this.updateShowing()
29 this.player().on('video-change', () => this.updateShowing())
22 } 30 }
23 31
24 buildCSSClass () { 32 buildCSSClass () {
@@ -36,7 +44,7 @@ class TheaterButton extends Button {
36 44
37 saveTheaterInStore(theaterEnabled) 45 saveTheaterInStore(theaterEnabled)
38 46
39 this.player_.trigger('theaterChange', theaterEnabled) 47 this.player_.trigger('theater-change', theaterEnabled)
40 } 48 }
41 49
42 handleClick () { 50 handleClick () {
@@ -48,6 +56,11 @@ class TheaterButton extends Button {
48 private isTheaterEnabled () { 56 private isTheaterEnabled () {
49 return this.player_.hasClass(TheaterButton.THEATER_MODE_CLASS) 57 return this.player_.hasClass(TheaterButton.THEATER_MODE_CLASS)
50 } 58 }
59
60 private updateShowing () {
61 if (this.theaterButtonOptions.isDisplayed()) this.show()
62 else this.hide()
63 }
51} 64}
52 65
53videojs.registerComponent('TheaterButton', TheaterButton) 66videojs.registerComponent('TheaterButton', TheaterButton)