mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
Fix HLS live check to handle fetch errors and improve polling logic
This commit is contained in:
@@ -274,10 +274,9 @@ function StreamPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setStreamReady(false)
|
const checkHlsLive = () => {
|
||||||
setHlsLive(null)
|
|
||||||
console.log("[HLS Check] Fetching manifest:", activePlayback.url)
|
console.log("[HLS Check] Fetching manifest:", activePlayback.url)
|
||||||
fetch(activePlayback.url)
|
fetch(activePlayback.url, { cache: "no-store" })
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
console.log("[HLS Check] Response status:", res.status, res.ok)
|
console.log("[HLS Check] Response status:", res.status, res.ok)
|
||||||
@@ -301,9 +300,19 @@ function StreamPage() {
|
|||||||
setHlsLive(false)
|
setHlsLive(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial check
|
||||||
|
setStreamReady(false)
|
||||||
|
setHlsLive(null)
|
||||||
|
checkHlsLive()
|
||||||
|
|
||||||
|
// Poll every 5 seconds to detect when stream goes live
|
||||||
|
const interval = setInterval(checkHlsLive, 5000)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
isActive = false
|
isActive = false
|
||||||
|
clearInterval(interval)
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
activePlayback?.type,
|
activePlayback?.type,
|
||||||
@@ -341,11 +350,13 @@ function StreamPage() {
|
|||||||
}
|
}
|
||||||
}, [activePlayback?.type, stream?.hls_url])
|
}, [activePlayback?.type, stream?.hls_url])
|
||||||
|
|
||||||
// For nikiv, use streamLive from the polled API status
|
// For nikiv, primarily use HLS live check from Cloudflare
|
||||||
|
// Fall back to streamLive status if HLS check hasn't completed
|
||||||
// For other users, use stream?.is_live from the database
|
// For other users, use stream?.is_live from the database
|
||||||
const isLiveStatus = username === "nikiv" ? streamLive : Boolean(stream?.is_live)
|
const isLiveStatus = username === "nikiv"
|
||||||
const isActuallyLive =
|
? (hlsLive === true || (hlsLive === null && streamLive))
|
||||||
isLiveStatus && (activePlayback?.type !== "hls" || hlsLive !== false)
|
: Boolean(stream?.is_live)
|
||||||
|
const isActuallyLive = isLiveStatus
|
||||||
const shouldFetchSpotify = username === "nikiv" && !isActuallyLive
|
const shouldFetchSpotify = username === "nikiv" && !isActuallyLive
|
||||||
|
|
||||||
// Debug logging for stream status
|
// Debug logging for stream status
|
||||||
|
|||||||
Reference in New Issue
Block a user