From e98ef69d1c8d4e39e45a52b04b3abf5fd1af3b2c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Jan 2022 09:42:54 +0100 Subject: Move to landscape on mobile fullscreen --- .../assets/player/mobile/peertube-mobile-plugin.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'client/src/assets') 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 @@ -import videojs from 'video.js' import './peertube-mobile-buttons' +import videojs from 'video.js' const Plugin = videojs.getPlugin('plugin') @@ -9,6 +9,23 @@ class PeerTubeMobilePlugin extends Plugin { super(player, options) player.addChild('PeerTubeMobileButtons') + + if (videojs.browser.IS_ANDROID && screen.orientation) { + this.handleFullscreenRotation() + } + } + + private handleFullscreenRotation () { + this.player.on('fullscreenchange', () => { + if (!this.player.isFullscreen() || this.isPortraitVideo()) return + + screen.orientation.lock('landscape') + .catch(err => console.error('Cannot lock screen to landscape.', err)) + }) + } + + private isPortraitVideo () { + return this.player.videoWidth() < this.player.videoHeight() } } -- cgit v1.2.3