diff options
Diffstat (limited to 'web/script/player/mod.ts')
-rw-r--r-- | web/script/player/mod.ts | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/web/script/player/mod.ts b/web/script/player/mod.ts index 0f30d45..c9c1ebc 100644 --- a/web/script/player/mod.ts +++ b/web/script/player/mod.ts @@ -37,6 +37,7 @@ function initialize_player(el: HTMLElement, node_id: string) { const logger = new Logger<string>(s => e("p", s)) const player = new Player(node_id, logger) const show_stats = new OVar(false); + const idle_inhibit = new OVar(false) const sync_state = new OVar<Playersync | undefined>(undefined) const toggle_playing = () => player.playing.value ? player.pause() : player.play() @@ -179,10 +180,14 @@ function initialize_player(el: HTMLElement, node_id: string) { ) el.append(pel) - mouse_idle(pel, 1000, idle => { - controls.style.opacity = idle ? "0" : "1" - pel.style.cursor = idle ? "none" : "default" - }) + controls.onmouseenter = () => idle_inhibit.value = true + controls.onmouseleave = () => idle_inhibit.value = false + mouse_idle(pel, 1000) + .liftA2(idle_inhibit, (x, y) => x && !y) + .onchangeinit(idle => { + controls.style.opacity = idle ? "0" : "1" + pel.style.cursor = idle ? "none" : "default" + }) player.video.addEventListener("click", toggle_playing) pri.addEventListener("mousedown", ev => { @@ -224,21 +229,22 @@ function send_player_progress(node_id: string, player: Player) { }, 10000) } -function mouse_idle(e: HTMLElement, timeout: number, cb: (b: boolean) => unknown) { +function mouse_idle(e: HTMLElement, timeout: number): OVar<boolean> { let ct: number; - let idle = false - e.onmouseleave = () => { clearTimeout(ct) } + const idle = new OVar(false) + // e.onmouseleave = () => { + // clearTimeout(ct) + // } e.onmousemove = () => { clearTimeout(ct) if (idle) { - idle = false - cb(idle) + idle.value = false } ct = setTimeout(() => { - idle = true - cb(idle) + idle.value = true }, timeout) } + return idle } function show_profile(profile: EncodingProfile): string { |