Wait indefinitely for media reacquire

This commit is contained in:
Max Goodhart
2026-01-26 22:07:49 -08:00
parent 1978bda59f
commit 029d80002c

View File

@@ -4,7 +4,6 @@ import { ContentDisplayOptions } from 'streamwall-shared'
const SCAN_THROTTLE = 500 const SCAN_THROTTLE = 500
const INITIAL_TIMEOUT = 10 * 1000 const INITIAL_TIMEOUT = 10 * 1000
const REACQUIRE_ELEMENT_TIMEOUT = 60 * 1000
const VIDEO_OVERRIDE_STYLE = ` const VIDEO_OVERRIDE_STYLE = `
* { * {
@@ -197,10 +196,11 @@ async function waitForVideo(
}> { }> {
lockdownMediaTags() lockdownMediaTags()
let video: Element | null | void = await Promise.race([ let queryPromise: Promise<Element | void> = waitForQuery(kind)
waitForQuery(kind), if (timeoutMs !== Infinity) {
sleep(timeoutMs), queryPromise = Promise.race([waitForQuery(kind), sleep(timeoutMs)])
]) }
let video: Element | null | void = await queryPromise
if (video instanceof HTMLMediaElement) { if (video instanceof HTMLMediaElement) {
return { video } return { video }
} }
@@ -317,7 +317,7 @@ async function main() {
ipcRenderer.send('view-stalled') ipcRenderer.send('view-stalled')
clearInterval(snapshotInterval) clearInterval(snapshotInterval)
const newMedia = await acquireMedia(REACQUIRE_ELEMENT_TIMEOUT) const newMedia = await acquireMedia(Infinity)
if (newMedia !== media) { if (newMedia !== media) {
media.remove() media.remove()
} }