1 import './peertube-mobile-buttons'
2 import videojs from 'video.js'
4 const Plugin = videojs.getPlugin('plugin')
6 class PeerTubeMobilePlugin extends Plugin {
8 constructor (player: videojs.Player, options: videojs.PlayerOptions) {
11 player.addChild('PeerTubeMobileButtons')
13 if (videojs.browser.IS_ANDROID && screen.orientation) {
14 this.handleFullscreenRotation()
18 private handleFullscreenRotation () {
19 this.player.on('fullscreenchange', () => {
20 if (!this.player.isFullscreen() || this.isPortraitVideo()) return
22 screen.orientation.lock('landscape')
23 .catch(err => console.error('Cannot lock screen to landscape.', err))
27 private isPortraitVideo () {
28 return this.player.videoWidth() < this.player.videoHeight()
32 videojs.registerPlugin('peertubeMobile', PeerTubeMobilePlugin)
33 export { PeerTubeMobilePlugin }