Skip to content

Commit

Permalink
feat: set label for vttPlaylist from label when available (#161)
Browse files Browse the repository at this point in the history
Co-authored-by: Roman Pylypets <roman.pylypets@lamin.ar>
  • Loading branch information
RomeroDiver and Roman Pylypets authored Oct 17, 2022
1 parent d1aeee9 commit 3fc0486
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/toM3u8.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const organizeAudioPlaylists = (playlists, sidxMapping = {}, isAudioOnly

export const organizeVttPlaylists = (playlists, sidxMapping = {}) => {
return playlists.reduce((a, playlist) => {
const label = playlist.attributes.lang || 'text';
const label = playlist.attributes.label || playlist.attributes.lang || 'text';

if (!a[label]) {
a[label] = {
Expand Down
17 changes: 17 additions & 0 deletions test/toM3u8.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,27 @@ QUnit.test('playlists with label', function(assert) {
type: 'static'
},
segments: []
}, {
attributes: {
sourceDuration: 100,
id: '1',
width: 800,
height: 600,
codecs: 'foo;bar',
duration: 0,
bandwidth: 10000,
periodStart: 0,
mimeType: 'text/vtt',
type: 'static',
label
},
segments: []
}];
const output = toM3u8({ dashPlaylists });

assert.ok(label in output.mediaGroups.AUDIO.audio, 'label exists');
assert.ok(label in output.mediaGroups.SUBTITLES.subs, 'label exists');

});

QUnit.test('608 captions', function(assert) {
Expand Down

0 comments on commit 3fc0486

Please sign in to comment.