From 80d2c819880b9d5b2e2aa298146b47e017d99fb7 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Mon, 23 Nov 2026 12:10:00 +0700 Subject: [PATCH 1/2] fix(player): attach native HLS readiness listener before load --- components/player/Player.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/player/Player.vue b/components/player/Player.vue index bd464058..543883d1 100644 --- a/components/player/Player.vue +++ b/components/player/Player.vue @@ -831,10 +831,9 @@ const configureHlsSource = async ( media.src = source.src; attachNativeHlsSongMetadata(media, version); - media.load(); if (autoplay && !userPaused.value) { - startFallbackProbe(); + // Register before load(): cached/native manifests can become ready immediately. media.addEventListener( "loadedmetadata", () => { @@ -843,7 +842,9 @@ const configureHlsSource = async ( }, { once: true }, ); + startFallbackProbe(); } + media.load(); return; } From c21eb553b41d9805ec53f98953acec655a7d53e7 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Mon, 23 Nov 2026 12:10:07 +0700 Subject: [PATCH 2/2] test(player): guard native HLS loadedmetadata registration order --- tests/player-hls-startup.test.mjs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/player-hls-startup.test.mjs b/tests/player-hls-startup.test.mjs index 1acd8313..3acccbcb 100644 --- a/tests/player-hls-startup.test.mjs +++ b/tests/player-hls-startup.test.mjs @@ -63,3 +63,17 @@ test("a failed hls.js import uses native HLS only when supported", async () => { assert.ok(nativeStart > 0 && nativeMetadata > nativeStart && nativeLoad > nativeMetadata, "native fallback reuses the existing source and metadata lifecycle"); }); + + +test("native HLS registers readiness before loading the stream", async () => { + const source = await readFile(playerPath, "utf8"); + const start = source.indexOf("const configureHlsSource"); + const end = source.indexOf("const stopPlaybackFailure", start); + const block = source.slice(start, end); + const nativeStart = block.indexOf("media.src = source.src;"); + const listener = block.indexOf('media.addEventListener(\n "loadedmetadata"', nativeStart); + const load = block.indexOf("media.load();", nativeStart); + + assert.ok(nativeStart >= 0 && listener > nativeStart && load > listener, + "native HLS can emit loadedmetadata synchronously after load(); listen first"); +});