Skip to content

Commit b48d2a5

Browse files
authored
fix: ensure vtt tracks language is set correctly (#181)
1 parent 5ea10f5 commit b48d2a5

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

src/toM3u8.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,11 @@ export const organizeAudioPlaylists = (playlists, sidxMapping = {}, isAudioOnly
246246
export const organizeVttPlaylists = (playlists, sidxMapping = {}) => {
247247
return playlists.reduce((a, playlist) => {
248248
const label = playlist.attributes.label || playlist.attributes.lang || 'text';
249+
const language = playlist.attributes.lang || 'und';
249250

250251
if (!a[label]) {
251252
a[label] = {
252-
language: label,
253+
language,
253254
default: false,
254255
autoselect: false,
255256
playlists: [],

test/toM3u8.test.js

+58-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ QUnit.test('playlists', function(assert) {
129129
text: {
130130
autoselect: false,
131131
default: false,
132-
language: 'text',
132+
language: 'und',
133133
playlists: [{
134134
attributes: {
135135
BANDWIDTH: 20000,
@@ -334,6 +334,22 @@ QUnit.test('playlists with content steering and resolvable URLs', function(asser
334334
sourceDuration: 0,
335335
type: 'dyanmic'
336336
}
337+
},
338+
{
339+
attributes: {
340+
bandwidth: 256,
341+
baseUrl: 'https://cdn3.example.com/vtt',
342+
clientOffset: 0,
343+
id: 'fr',
344+
label: 'french',
345+
lang: 'fr',
346+
mimeType: 'text/vtt',
347+
periodStart: 0,
348+
role: {},
349+
serviceLocation: 'beta',
350+
sourceDuration: 0,
351+
type: 'dyanmic'
352+
}
337353
}
338354
];
339355

@@ -353,6 +369,45 @@ QUnit.test('playlists with content steering and resolvable URLs', function(asser
353369
['CLOSED-CAPTIONS']: {},
354370
SUBTITLES: {
355371
subs: {
372+
french: {
373+
autoselect: false,
374+
default: false,
375+
language: 'fr',
376+
playlists: [
377+
{
378+
attributes: {
379+
BANDWIDTH: 256,
380+
NAME: 'fr',
381+
['PROGRAM-ID']: 1,
382+
serviceLocation: 'beta'
383+
},
384+
discontinuitySequence: 0,
385+
discontinuityStarts: [],
386+
endList: false,
387+
mediaSequence: 0,
388+
resolvedUri: 'https://cdn3.example.com/vtt',
389+
segments: [
390+
{
391+
duration: 0,
392+
number: 0,
393+
resolvedUri: 'https://cdn3.example.com/vtt',
394+
timeline: 0,
395+
uri: 'https://cdn3.example.com/vtt'
396+
}
397+
],
398+
targetDuration: 0,
399+
timeline: 0,
400+
timelineStarts: [
401+
{
402+
start: 0,
403+
timeline: 0
404+
}
405+
],
406+
uri: ''
407+
}
408+
],
409+
uri: ''
410+
},
356411
en: {
357412
autoselect: false,
358413
default: false,
@@ -1060,7 +1115,7 @@ QUnit.test('playlists with segments', function(assert) {
10601115
text: {
10611116
autoselect: false,
10621117
default: false,
1063-
language: 'text',
1118+
language: 'und',
10641119
playlists: [{
10651120
attributes: {
10661121
BANDWIDTH: 20000,
@@ -1893,7 +1948,7 @@ QUnit.test('eventStreams with playlists', function(assert) {
18931948
text: {
18941949
autoselect: false,
18951950
default: false,
1896-
language: 'text',
1951+
language: 'und',
18971952
playlists: [{
18981953
attributes: {
18991954
BANDWIDTH: 20000,

0 commit comments

Comments
 (0)