aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/mobile
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-01-11 11:26:35 +0100
committerChocobozzz <me@florianbigard.com>2022-01-11 11:26:35 +0100
commitf1a0555a88db9ade2b073a2e4dc73c4a6176c8a0 (patch)
treee1f73376527152fb9ac92447a826bccc9e8f0dd5 /client/src/assets/player/mobile
parentba9eef5f628764aed6183135e669b17741d24d7a (diff)
downloadPeerTube-f1a0555a88db9ade2b073a2e4dc73c4a6176c8a0.tar.gz
PeerTube-f1a0555a88db9ade2b073a2e4dc73c4a6176c8a0.tar.zst
PeerTube-f1a0555a88db9ade2b073a2e4dc73c4a6176c8a0.zip
Add player controls on mobile
Diffstat (limited to 'client/src/assets/player/mobile')
-rw-r--r--client/src/assets/player/mobile/peertube-mobile-buttons.ts42
-rw-r--r--client/src/assets/player/mobile/peertube-mobile-plugin.ts16
2 files changed, 58 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 @@
1import videojs from 'video.js'
2
3import debug from 'debug'
4
5const logger = debug('peertube:player:mobile')
6
7const Component = videojs.getComponent('Component')
8class 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
42videojs.registerComponent('PeerTubeMobileButtons', PeerTubeMobileButtons)
diff --git a/client/src/assets/player/mobile/peertube-mobile-plugin.ts b/client/src/assets/player/mobile/peertube-mobile-plugin.ts
new file mode 100644
index 000000000..b3834e20d
--- /dev/null
+++ b/client/src/assets/player/mobile/peertube-mobile-plugin.ts
@@ -0,0 +1,16 @@
1import videojs from 'video.js'
2import './peertube-mobile-buttons'
3
4const Plugin = videojs.getPlugin('plugin')
5
6class PeerTubeMobilePlugin extends Plugin {
7
8 constructor (player: videojs.Player, options: videojs.PlayerOptions) {
9 super(player, options)
10
11 player.addChild('PeerTubeMobileButtons')
12 }
13}
14
15videojs.registerPlugin('peertubeMobile', PeerTubeMobilePlugin)
16export { PeerTubeMobilePlugin }