From 13a0e6ceeddc99a895c36f597ae6b388caebfce4 Mon Sep 17 00:00:00 2001 From: Astounds Date: Sun, 5 Apr 2026 18:31:35 -0500 Subject: fix(hls): improve audio track selection and auto-detect "Original" - Auto-select "Original" audio track by default in both native and Plyr HLS players - Fix native HLS audio selector to use numeric indices instead of string matching - Robustly detect "original" track by checking both `name` and `lang` attributes - Fix audio track change handler to correctly switch between available tracks --- youtube/static/js/plyr.hls.start.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'youtube/static/js/plyr.hls.start.js') diff --git a/youtube/static/js/plyr.hls.start.js b/youtube/static/js/plyr.hls.start.js index 91e0221..bc8ec23 100644 --- a/youtube/static/js/plyr.hls.start.js +++ b/youtube/static/js/plyr.hls.start.js @@ -361,9 +361,11 @@ if (hlsInstance && hlsInstance.audioTracks && hlsInstance.audioTracks.length > 0) { // Prefer "original" audio track - const originalIdx = hlsInstance.audioTracks.findIndex(t => - (t.name || '').toLowerCase().includes('original') - ); + const originalIdx = hlsInstance.audioTracks.findIndex(t => { + const name = (t.name || '').toLowerCase(); + const lang = (t.lang || '').toLowerCase(); + return name.includes('original') || lang === 'original'; + }); if (originalIdx !== -1) { hlsInstance.audioTrack = originalIdx; console.log('Selected original audio track:', hlsInstance.audioTracks[originalIdx].name); -- cgit v1.2.3