X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fpeertube-plugin.ts;h=a2b038b775693792813505ee6fb8e73c13a456be;hb=35f0a5e665a565ffc9d4b88c5a12d45c88b0a090;hp=19d1046769281f0738f084e9d0563b3574c41850;hpb=a30a136c9896c656cab98d2c92cde32c534dc098;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts index 19d104676..a2b038b77 100644 --- a/client/src/assets/player/peertube-plugin.ts +++ b/client/src/assets/player/peertube-plugin.ts @@ -1,4 +1,4 @@ -import videojs, { VideoJsPlayer } from 'video.js' +import videojs from 'video.js' import './videojs-components/settings-menu-button' import { PeerTubePluginOptions, @@ -36,7 +36,7 @@ class PeerTubePlugin extends Plugin { private mouseInControlBar = false private readonly savedInactivityTimeout: number - constructor (player: VideoJsPlayer, options?: PeerTubePluginOptions) { + constructor (player: videojs.Player, options?: PeerTubePluginOptions) { super(player) this.videoViewUrl = options.videoViewUrl @@ -45,7 +45,7 @@ class PeerTubePlugin extends Plugin { this.savedInactivityTimeout = player.options_.inactivityTimeout - if (options.autoplay === true) this.player.addClass('vjs-has-autoplay') + if (options.autoplay) this.player.addClass('vjs-has-autoplay') this.player.on('autoplay-failure', () => { this.player.removeClass('vjs-has-autoplay') @@ -233,12 +233,20 @@ class PeerTubePlugin extends Plugin { } private alterInactivity () { - if (this.menuOpened || this.mouseInControlBar) { + if (this.menuOpened) { this.player.options_.inactivityTimeout = this.savedInactivityTimeout return } - this.player.options_.inactivityTimeout = 1 + if (!this.mouseInControlBar && !this.isTouchEnabled()) { + this.player.options_.inactivityTimeout = 1 + } + } + + private isTouchEnabled () { + return ('ontouchstart' in window) || + navigator.maxTouchPoints > 0 || + navigator.msMaxTouchPoints > 0 } private initCaptions () {