diff options
Diffstat (limited to 'client/src/assets/player/mobile/peertube-mobile-buttons.ts')
-rw-r--r-- | client/src/assets/player/mobile/peertube-mobile-buttons.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/client/src/assets/player/mobile/peertube-mobile-buttons.ts b/client/src/assets/player/mobile/peertube-mobile-buttons.ts new file mode 100644 index 000000000..d6f8f35e3 --- /dev/null +++ b/client/src/assets/player/mobile/peertube-mobile-buttons.ts | |||
@@ -0,0 +1,42 @@ | |||
1 | import videojs from 'video.js' | ||
2 | |||
3 | import debug from 'debug' | ||
4 | |||
5 | const logger = debug('peertube:player:mobile') | ||
6 | |||
7 | const Component = videojs.getComponent('Component') | ||
8 | class PeerTubeMobileButtons extends Component { | ||
9 | |||
10 | createEl () { | ||
11 | const container = super.createEl('div', { | ||
12 | className: 'vjs-mobile-buttons-overlay' | ||
13 | }) as HTMLDivElement | ||
14 | |||
15 | container.addEventListener('click', () => { | ||
16 | logger('Set user as inactive') | ||
17 | |||
18 | this.player_.userActive(false) | ||
19 | }) | ||
20 | |||
21 | const mainButton = super.createEl('div', { | ||
22 | className: 'main-button' | ||
23 | }) as HTMLDivElement | ||
24 | |||
25 | mainButton.addEventListener('click', e => { | ||
26 | e.stopPropagation() | ||
27 | |||
28 | if (this.player_.paused() || this.player_.ended()) { | ||
29 | this.player_.play() | ||
30 | return | ||
31 | } | ||
32 | |||
33 | this.player_.pause() | ||
34 | }) | ||
35 | |||
36 | container.appendChild(mainButton) | ||
37 | |||
38 | return container | ||
39 | } | ||
40 | } | ||
41 | |||
42 | videojs.registerComponent('PeerTubeMobileButtons', PeerTubeMobileButtons) | ||