Menu

My auto-hide controls kept flickering in ArtPlayer v5: the dual-timer fight and the 1.5s immunity fix
📰

My auto-hide controls kept flickering in ArtPlayer v5: the dual-timer fight and the 1.5s immunity fix

DEV Community: android·hammi·12 days ago
#sObdktxB
#devtoandroid#devto#dev#controls#timer
Reading 0:00
15s threshold

I'm building RKMovies ( a tiny 4K player for old phones ) — 0.91 MB APK, hardware decode, no accounts, no tracking. The player UI runs on ArtPlayer v5, and I replaced its default controls with my own auto-hide layer. That layer flickered for weeks. Here's why.

ArtPlayer hides its controls on its own timer. Every timeupdate it checks controls.timer ; if the controls have been idle for a few seconds it hides them and hides the cursor.

I wanted different rules: never hide while the settings panel is open, while paused, or while the user is scrubbing, plus a minimum visible time of 1s. So I added my own hideTimer (3.5s) with those guards.

Two timers, two sources of truth. ArtPlayer's internal check and my setTimeout disagreed about when to hide, so the controls flickered: my layer showed them, the library's next timeupdate hid them, mine showed them again.

The fix wasn't a second timer fighting the first. It was a 1.5s immunity lock.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.