Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Commit

Permalink
Add fix for playlist not updating when only endList changes on the pl…
Browse files Browse the repository at this point in the history
…aylist
  • Loading branch information
Henry Pate committed May 17, 2018
1 parent a3ecfd0 commit dd146ad
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ export const updateMaster = (master, media) => {
return null;
}

// consider the playlist unchanged if the number of segments is equal and the media
// sequence number is unchanged
// consider the playlist unchanged if the number of segments is equal, the media
// sequence number is unchanged, and this playlist hasn't become the end of the playlist
if (playlist.segments &&
media.segments &&
playlist.segments.length === media.segments.length &&
playlist.endList === media.endList &&
playlist.mediaSequence === media.mediaSequence) {
return null;
}
Expand Down
45 changes: 45 additions & 0 deletions test/playlist-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,51 @@ QUnit.test('updateMaster updates master when new media sequence', function(asser
'updates master when new media sequence');
});

QUnit.test('updateMaster updates master when endList changes', function(assert) {
const playlist = {
endList: false,
mediaSequence: 0,
attributes: {
BANDWIDTH: 9
},
uri: 'playlist-0-uri',
resolvedUri: urlTo('playlist-0-uri'),
segments: [{
duration: 10,
uri: 'segment-0-uri',
resolvedUri: urlTo('segment-0-uri')
}]
};

const master = {
playlists: [playlist]
};

const media = Object.assign({}, playlist, {
endList: true
});

assert.deepEqual(
updateMaster(master, media),
{
playlists: [{
endList: true,
mediaSequence: 0,
attributes: {
BANDWIDTH: 9
},
uri: 'playlist-0-uri',
resolvedUri: urlTo('playlist-0-uri'),
segments: [{
duration: 10,
uri: 'segment-0-uri',
resolvedUri: urlTo('segment-0-uri')
}]
}]
},
'updates master when endList changes');
});

QUnit.test('updateMaster retains top level values in master', function(assert) {
const master = {
mediaGroups: {
Expand Down

0 comments on commit dd146ad

Please sign in to comment.