Fix mobile buttons in player

This commit is contained in:
Chocobozzz 2024-09-19 09:48:56 +02:00
parent e03dfa6c82
commit 7d3a9cabdc
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 18 additions and 7 deletions

View File

@ -88,7 +88,7 @@ class PeerTubeMobilePlugin extends Plugin {
} }
private initTouchStartEvents () { private initTouchStartEvents () {
const handleTouchStart = (event: TouchEvent) => { const handleTouchStart = (event: TouchEvent, onlyDetectDoubleTap = false) => {
debugLogger('Handle touch start') debugLogger('Handle touch start')
if (this.tapTimeout) { if (this.tapTimeout) {
@ -107,10 +107,12 @@ class PeerTubeMobilePlugin extends Plugin {
return return
} }
if (onlyDetectDoubleTap) return
this.newActiveState = !this.player.userActive() this.newActiveState = !this.player.userActive()
// video.js forces userActive on tap so we prevent this behaviour with a custom class // video.js forces userActive on tap so we prevent this behaviour with a custom class
if (this.newActiveState === true) { if (!this.player.paused() && this.newActiveState === true) {
this.player.addClass('vjs-force-inactive') this.player.addClass('vjs-force-inactive')
} }
@ -125,7 +127,10 @@ class PeerTubeMobilePlugin extends Plugin {
} }
this.onTouchStartHandler = event => { this.onTouchStartHandler = event => {
handleTouchStart(event) // If user is active, only listen to mobile button overlay events to know if we need to hide them
const onlyDetectDoubleTap = this.player.userActive()
handleTouchStart(event, onlyDetectDoubleTap)
} }
this.player.on('touchstart', this.onTouchStartHandler) this.player.on('touchstart', this.onTouchStartHandler)
@ -190,12 +195,15 @@ class PeerTubeMobilePlugin extends Plugin {
this.seekAmount = 0 this.seekAmount = 0
this.peerTubeMobileButtons.displayFastSeek(0) this.peerTubeMobileButtons.displayFastSeek(0)
this.player.removeClass('vjs-fast-seeking')
this.player.removeClass('vjs-force-inactive')
this.player.userActive(false) this.player.userActive(false)
this.doubleTapping = false this.doubleTapping = false
this.player.play() this.player.play()
setTimeout(() => {
this.player.removeClass('vjs-fast-seeking')
this.player.removeClass('vjs-force-inactive')
}, 100)
}, PeerTubeMobilePlugin.SET_CURRENT_TIME_DELAY) }, PeerTubeMobilePlugin.SET_CURRENT_TIME_DELAY)
} }
} }

View File

@ -186,8 +186,11 @@
} }
} }
.vjs-force-inactive .vjs-control-bar { .vjs-force-inactive,
display: none; .vjs-fast-seeking {
.vjs-control-bar {
display: none;
}
} }
@keyframes fadeInAndOut { @keyframes fadeInAndOut {