Skip to content

Commit 20b87f3

Browse files
Sbussisoclaude
andcommitted
fix: force HLS player to start from live edge on every page load
- Set autoStartLoad: false to prevent hls.js from loading segments before MANIFEST_PARSED, where we explicitly call startLoad(-1) to begin at the live edge - Add Cache-Control: no-cache to XHR requests so the browser always revalidates playlists/segments with the server instead of serving stale HTTP-cached responses Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c6b20ec commit 20b87f3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

frontend/src/components/HlsPlayer.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ function HlsPlayer({ cameraId, cameraName }) {
3737

3838
if (Hls.isSupported()) {
3939
const hls = new Hls({
40+
// Don't auto-start loading — we call startLoad(-1)
41+
// in MANIFEST_PARSED to ensure playback always begins
42+
// from the live edge, not from a stale buffer position.
43+
autoStartLoad: false,
44+
4045
xhrSetup: (xhr, url) => {
41-
// Send the shared auth token to our own backend.
42-
// Live segments are served same-origin from the
43-
// backend proxy, so the Authorization header rides
44-
// along with every fetch — no presigned URLs.
4546
const token = LOCAL_TEST_MODE ? null : getCurrentToken()
4647
if (token && url.startsWith(ownOrigin)) {
4748
xhr.setRequestHeader("Authorization", `Bearer ${token}`)
49+
// Prevent browser from serving cached playlist/segment
50+
xhr.setRequestHeader("Cache-Control", "no-cache")
4851
}
4952
},
5053

0 commit comments

Comments
 (0)