Skip to content

Commit 69d0d6d

Browse files
committed
Prevent immediate hiding of controls on mobile
1 parent fac134d commit 69d0d6d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/js/listeners.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ class Listeners {
620620
return;
621621
}
622622

623+
// Record seek time so we can prevent hiding controls for a few seconds after seek
624+
player.lastSeekTime = Date.now();
625+
623626
// Was playing before?
624627
const play = seek.hasAttribute(attribute);
625628

src/js/plyr.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ class Plyr {
302302
if (this.config.autoplay) {
303303
this.play();
304304
}
305+
306+
// Seek time will be recorded (in listeners.js) so we can prevent hiding controls for a few seconds after seek
307+
this.lastSeekTime = 0;
305308
}
306309

307310
// ---------------------------------------

src/js/ui.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ const ui = {
247247
const { controls } = this.elements;
248248

249249
if (controls && this.config.hideControls) {
250-
// Show controls if force, loading, paused, or button interaction, otherwise hide
251-
this.toggleControls(Boolean(force || this.loading || this.paused || controls.pressed || controls.hover));
250+
// Don't hide controls if a touch-device user recently seeked. (Must be limited to touch devices, or it occasionally prevents desktop controls from hiding.)
251+
const recentTouchSeek = (this.touch && this.lastSeekTime + 2000 > Date.now());
252+
253+
// Show controls if force, loading, paused, button interaction, or recent seek, otherwise hide
254+
this.toggleControls(Boolean(force || this.loading || this.paused || controls.pressed || controls.hover || recentTouchSeek));
252255
}
253256
},
254257
};

0 commit comments

Comments
 (0)