diff options
author | Chocobozzz <me@florianbigard.com> | 2022-01-11 11:26:35 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-01-11 11:26:35 +0100 |
commit | f1a0555a88db9ade2b073a2e4dc73c4a6176c8a0 (patch) | |
tree | e1f73376527152fb9ac92447a826bccc9e8f0dd5 /client/src/assets/player/mobile | |
parent | ba9eef5f628764aed6183135e669b17741d24d7a (diff) | |
download | PeerTube-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.ts | 42 | ||||
-rw-r--r-- | client/src/assets/player/mobile/peertube-mobile-plugin.ts | 16 |
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 @@ | |||
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) | ||
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 @@ | |||
1 | import videojs from 'video.js' | ||
2 | import './peertube-mobile-buttons' | ||
3 | |||
4 | const Plugin = videojs.getPlugin('plugin') | ||
5 | |||
6 | class PeerTubeMobilePlugin extends Plugin { | ||
7 | |||
8 | constructor (player: videojs.Player, options: videojs.PlayerOptions) { | ||
9 | super(player, options) | ||
10 | |||
11 | player.addChild('PeerTubeMobileButtons') | ||
12 | } | ||
13 | } | ||
14 | |||
15 | videojs.registerPlugin('peertubeMobile', PeerTubeMobilePlugin) | ||
16 | export { PeerTubeMobilePlugin } | ||