Skip to content

Commit

Permalink
dont pass type directly but a flag whether to use NAME for id
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev committed Sep 22, 2020
1 parent c20e105 commit f48f657
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ export const setupMediaPlaylist = ({ playlist, uri, id }) => {
*
* @param {Object} master
* The master playlist
* @param {boolean} [useNameForId=false]
* Whether we should use the NAME property for ID.
* Generally only used for DASH and defaults to false.
*/
export const setupMediaPlaylists = (master, type) => {
export const setupMediaPlaylists = (master, useNameForId) => {
let i = master.playlists.length;

while (i--) {
Expand All @@ -110,7 +113,7 @@ export const setupMediaPlaylists = (master, type) => {

// DASH Representations can change order across refreshes which can make referring to them by index not work
// Instead, use the provided id, available via the NAME attribute.
if (type === 'dash') {
if (useNameForId) {
id = playlist.attributes && playlist.attributes.NAME || id;
}

Expand Down Expand Up @@ -197,8 +200,11 @@ export const masterForMedia = (media, uri) => {
* Master manifest object
* @param {string} uri
* The source URI
* @param {boolean} [useNameForId=false]
* Whether we should use the NAME property for ID.
* Generally only used for DASH and defaults to false.
*/
export const addPropertiesToMaster = (master, uri, type) => {
export const addPropertiesToMaster = (master, uri, useNameForId = false) => {
master.uri = uri;

for (let i = 0; i < master.playlists.length; i++) {
Expand Down Expand Up @@ -231,6 +237,6 @@ export const addPropertiesToMaster = (master, uri, type) => {
master.playlists[phonyUri] = properties.playlists[0];
});

setupMediaPlaylists(master, type);
setupMediaPlaylists(master, useNameForId);
resolveMediaGroupUris(master);
};
2 changes: 1 addition & 1 deletion src/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export default class PlaylistLoader extends EventTarget {

if (manifest.playlists) {
this.master = manifest;
addPropertiesToMaster(this.master, this.srcUri(), 'hls');
addPropertiesToMaster(this.master, this.srcUri());
// If the initial master playlist has playlists wtih segments already resolved,
// then resolve URIs in advance, as they are usually done after a playlist request,
// which may not happen if the playlist is resolved.
Expand Down

0 comments on commit f48f657

Please sign in to comment.