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
This commit is contained in:
2026-04-05 18:31:35 -05:00
parent e8e2aa93d6
commit 13a0e6ceed
2 changed files with 24 additions and 16 deletions

View File

@@ -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);