diff options
author | Chocobozzz <me@florianbigard.com> | 2022-01-12 09:42:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-01-12 09:42:54 +0100 |
commit | e98ef69d1c8d4e39e45a52b04b3abf5fd1af3b2c (patch) | |
tree | 5ccc3f7ca279a1112077a55fc95bc8155364f90c /client/src/assets/player | |
parent | f1a0555a88db9ade2b073a2e4dc73c4a6176c8a0 (diff) | |
download | PeerTube-e98ef69d1c8d4e39e45a52b04b3abf5fd1af3b2c.tar.gz PeerTube-e98ef69d1c8d4e39e45a52b04b3abf5fd1af3b2c.tar.zst PeerTube-e98ef69d1c8d4e39e45a52b04b3abf5fd1af3b2c.zip |
Move to landscape on mobile fullscreen
Diffstat (limited to 'client/src/assets/player')
-rw-r--r-- | client/src/assets/player/mobile/peertube-mobile-plugin.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/client/src/assets/player/mobile/peertube-mobile-plugin.ts b/client/src/assets/player/mobile/peertube-mobile-plugin.ts index b3834e20d..2ce6b4b33 100644 --- a/client/src/assets/player/mobile/peertube-mobile-plugin.ts +++ b/client/src/assets/player/mobile/peertube-mobile-plugin.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import videojs from 'video.js' | ||
2 | import './peertube-mobile-buttons' | 1 | import './peertube-mobile-buttons' |
2 | import videojs from 'video.js' | ||
3 | 3 | ||
4 | const Plugin = videojs.getPlugin('plugin') | 4 | const Plugin = videojs.getPlugin('plugin') |
5 | 5 | ||
@@ -9,6 +9,23 @@ class PeerTubeMobilePlugin extends Plugin { | |||
9 | super(player, options) | 9 | super(player, options) |
10 | 10 | ||
11 | player.addChild('PeerTubeMobileButtons') | 11 | player.addChild('PeerTubeMobileButtons') |
12 | |||
13 | if (videojs.browser.IS_ANDROID && screen.orientation) { | ||
14 | this.handleFullscreenRotation() | ||
15 | } | ||
16 | } | ||
17 | |||
18 | private handleFullscreenRotation () { | ||
19 | this.player.on('fullscreenchange', () => { | ||
20 | if (!this.player.isFullscreen() || this.isPortraitVideo()) return | ||
21 | |||
22 | screen.orientation.lock('landscape') | ||
23 | .catch(err => console.error('Cannot lock screen to landscape.', err)) | ||
24 | }) | ||
25 | } | ||
26 | |||
27 | private isPortraitVideo () { | ||
28 | return this.player.videoWidth() < this.player.videoHeight() | ||
12 | } | 29 | } |
13 | } | 30 | } |
14 | 31 | ||