Prevent immediate hiding of controls on mobile
This commit is contained in:
parent
fac134dd95
commit
69d0d6d7ee
@ -620,6 +620,9 @@ class Listeners {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Record seek time so we can prevent hiding controls for a few seconds after seek
|
||||||
|
player.lastSeekTime = Date.now();
|
||||||
|
|
||||||
// Was playing before?
|
// Was playing before?
|
||||||
const play = seek.hasAttribute(attribute);
|
const play = seek.hasAttribute(attribute);
|
||||||
|
|
||||||
|
@ -302,6 +302,9 @@ class Plyr {
|
|||||||
if (this.config.autoplay) {
|
if (this.config.autoplay) {
|
||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seek time will be recorded (in listeners.js) so we can prevent hiding controls for a few seconds after seek
|
||||||
|
this.lastSeekTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
|
@ -247,8 +247,11 @@ const ui = {
|
|||||||
const { controls } = this.elements;
|
const { controls } = this.elements;
|
||||||
|
|
||||||
if (controls && this.config.hideControls) {
|
if (controls && this.config.hideControls) {
|
||||||
// Show controls if force, loading, paused, or button interaction, otherwise hide
|
// 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.)
|
||||||
this.toggleControls(Boolean(force || this.loading || this.paused || controls.pressed || controls.hover));
|
const recentTouchSeek = (this.touch && this.lastSeekTime + 2000 > Date.now());
|
||||||
|
|
||||||
|
// Show controls if force, loading, paused, button interaction, or recent seek, otherwise hide
|
||||||
|
this.toggleControls(Boolean(force || this.loading || this.paused || controls.pressed || controls.hover || recentTouchSeek));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user