From b48d2a5488cbb28388e041f72b600f35d2f15fdc Mon Sep 17 00:00:00 2001 From: Walter Seymour Date: Wed, 9 Oct 2024 13:42:17 -0500 Subject: [PATCH] fix: ensure vtt tracks language is set correctly (#181) --- src/toM3u8.js | 3 ++- test/toM3u8.test.js | 61 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/toM3u8.js b/src/toM3u8.js index 287f7da..286c2a5 100644 --- a/src/toM3u8.js +++ b/src/toM3u8.js @@ -246,10 +246,11 @@ export const organizeAudioPlaylists = (playlists, sidxMapping = {}, isAudioOnly export const organizeVttPlaylists = (playlists, sidxMapping = {}) => { return playlists.reduce((a, playlist) => { const label = playlist.attributes.label || playlist.attributes.lang || 'text'; + const language = playlist.attributes.lang || 'und'; if (!a[label]) { a[label] = { - language: label, + language, default: false, autoselect: false, playlists: [], diff --git a/test/toM3u8.test.js b/test/toM3u8.test.js index 6d28e6b..9d765a8 100644 --- a/test/toM3u8.test.js +++ b/test/toM3u8.test.js @@ -129,7 +129,7 @@ QUnit.test('playlists', function(assert) { text: { autoselect: false, default: false, - language: 'text', + language: 'und', playlists: [{ attributes: { BANDWIDTH: 20000, @@ -334,6 +334,22 @@ QUnit.test('playlists with content steering and resolvable URLs', function(asser sourceDuration: 0, type: 'dyanmic' } + }, + { + attributes: { + bandwidth: 256, + baseUrl: 'https://cdn3.example.com/vtt', + clientOffset: 0, + id: 'fr', + label: 'french', + lang: 'fr', + mimeType: 'text/vtt', + periodStart: 0, + role: {}, + serviceLocation: 'beta', + sourceDuration: 0, + type: 'dyanmic' + } } ]; @@ -353,6 +369,45 @@ QUnit.test('playlists with content steering and resolvable URLs', function(asser ['CLOSED-CAPTIONS']: {}, SUBTITLES: { subs: { + french: { + autoselect: false, + default: false, + language: 'fr', + playlists: [ + { + attributes: { + BANDWIDTH: 256, + NAME: 'fr', + ['PROGRAM-ID']: 1, + serviceLocation: 'beta' + }, + discontinuitySequence: 0, + discontinuityStarts: [], + endList: false, + mediaSequence: 0, + resolvedUri: 'https://cdn3.example.com/vtt', + segments: [ + { + duration: 0, + number: 0, + resolvedUri: 'https://cdn3.example.com/vtt', + timeline: 0, + uri: 'https://cdn3.example.com/vtt' + } + ], + targetDuration: 0, + timeline: 0, + timelineStarts: [ + { + start: 0, + timeline: 0 + } + ], + uri: '' + } + ], + uri: '' + }, en: { autoselect: false, default: false, @@ -1060,7 +1115,7 @@ QUnit.test('playlists with segments', function(assert) { text: { autoselect: false, default: false, - language: 'text', + language: 'und', playlists: [{ attributes: { BANDWIDTH: 20000, @@ -1893,7 +1948,7 @@ QUnit.test('eventStreams with playlists', function(assert) { text: { autoselect: false, default: false, - language: 'text', + language: 'und', playlists: [{ attributes: { BANDWIDTH: 20000,