Skip to content

Commit

Permalink
fix: ensure vtt tracks language is set correctly (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
wseymour15 authored Oct 9, 2024
1 parent 5ea10f5 commit b48d2a5
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/toM3u8.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
61 changes: 58 additions & 3 deletions test/toM3u8.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ QUnit.test('playlists', function(assert) {
text: {
autoselect: false,
default: false,
language: 'text',
language: 'und',
playlists: [{
attributes: {
BANDWIDTH: 20000,
Expand Down Expand Up @@ -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'
}
}
];

Expand All @@ -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,
Expand Down Expand Up @@ -1060,7 +1115,7 @@ QUnit.test('playlists with segments', function(assert) {
text: {
autoselect: false,
default: false,
language: 'text',
language: 'und',
playlists: [{
attributes: {
BANDWIDTH: 20000,
Expand Down Expand Up @@ -1893,7 +1948,7 @@ QUnit.test('eventStreams with playlists', function(assert) {
text: {
autoselect: false,
default: false,
language: 'text',
language: 'und',
playlists: [{
attributes: {
BANDWIDTH: 20000,
Expand Down

0 comments on commit b48d2a5

Please sign in to comment.