Skip to content

Commit

Permalink
fix: retain playlist attributes when refreshing live media playlists (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben committed Apr 13, 2022
1 parent b98877d commit 5fbac16
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export const updateMaster = (master, newMedia, unchangedCheck = isPlaylistUnchan
}
for (let i = 0; i < properties.playlists.length; i++) {
if (newMedia.id === properties.playlists[i].id) {
properties.playlists[i] = newMedia;
properties.playlists[i] = mergedPlaylist;
}
}
});
Expand Down
104 changes: 104 additions & 0 deletions test/playlist-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,110 @@ QUnit.module('Playlist Loader', function(hooks) {
assert.deepEqual(result, master, 'playlist updated');
});

QUnit.test('updateMaster retains mediaGroup attributes', function(assert) {
const master = {
mediaGroups: {
AUDIO: {
'GROUP-ID': {
default: {
default: true,
playlists: [{
mediaSequence: 0,
attributes: {
BANDWIDTH: 9,
CODECS: 'mp4a.40.2'
},
id: 'playlist-0-uri',
uri: 'playlist-0-uri',
resolvedUri: urlTo('playlist-0-uri'),
segments: [{
duration: 10,
uri: 'segment-0-uri',
resolvedUri: urlTo('segment-0-uri')
}]
}]
}
}
}
},
playlists: [{
mediaSequence: 0,
attributes: {
BANDWIDTH: 9,
CODECS: 'mp4a.40.2'
},
id: 'playlist-0-uri',
uri: 'playlist-0-uri',
resolvedUri: urlTo('playlist-0-uri'),
segments: [{
duration: 10,
uri: 'segment-0-uri',
resolvedUri: urlTo('segment-0-uri')
}]
}]
};
const media = {
mediaSequence: 1,
attributes: {
BANDWIDTH: 9
},
id: 'playlist-0-uri',
uri: 'playlist-0-uri',
segments: [{
duration: 10,
uri: 'segment-0-uri'
}]
};

master.playlists[media.id] = master.playlists[0];

assert.deepEqual(
updateMaster(master, media),
{
mediaGroups: {
AUDIO: {
'GROUP-ID': {
default: {
default: true,
playlists: [{
mediaSequence: 1,
attributes: {
BANDWIDTH: 9,
CODECS: 'mp4a.40.2'
},
id: 'playlist-0-uri',
uri: 'playlist-0-uri',
resolvedUri: urlTo('playlist-0-uri'),
segments: [{
duration: 10,
uri: 'segment-0-uri',
resolvedUri: urlTo('segment-0-uri')
}]
}]
}
}
}
},
playlists: [{
mediaSequence: 1,
attributes: {
BANDWIDTH: 9,
CODECS: 'mp4a.40.2'
},
id: 'playlist-0-uri',
uri: 'playlist-0-uri',
resolvedUri: urlTo('playlist-0-uri'),
segments: [{
duration: 10,
uri: 'segment-0-uri',
resolvedUri: urlTo('segment-0-uri')
}]
}]
},
'updated playlist retains codec attribute'
);
});

QUnit.test('uses last segment duration for refresh delay', function(assert) {
const media = { targetDuration: 7, segments: [] };

Expand Down

0 comments on commit 5fbac16

Please sign in to comment.