Browse Source

Move to landscape on mobile fullscreen

pull/4723/head
Chocobozzz 1 week ago
parent
commit
e98ef69d1c
No known key found for this signature in database GPG Key ID: 583A612D890159BE
1 changed files with 18 additions and 1 deletions
  1. +18
    -1
      client/src/assets/player/mobile/peertube-mobile-plugin.ts

+ 18
- 1
client/src/assets/player/mobile/peertube-mobile-plugin.ts View File

@@ -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()
}
}



Loading…
Cancel
Save