From f48bb8d0e86e873378505912d8fbe66f4505a065 Mon Sep 17 00:00:00 2001 From: ldayananda Date: Mon, 11 Mar 2019 16:42:10 -0400 Subject: [PATCH] update to only add segments if there is a sidx box parsed. Fix tests --- src/index.js | 2 +- src/toM3u8.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 971e0505..1a681036 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,7 @@ import { parseUTCTimingScheme } from './parseUTCTimingScheme'; export const VERSION = version; -export const parse = (manifestString, options) => +export const parse = (manifestString, options = {}) => toM3u8(toPlaylists(inheritAttributes(stringToMpdXml(manifestString), options)), options.sidxMapping); /** diff --git a/src/toM3u8.js b/src/toM3u8.js index f7e92a82..58629197 100644 --- a/src/toM3u8.js +++ b/src/toM3u8.js @@ -47,10 +47,10 @@ const addSegmentInfoFromSidx = (playlists, sidxMapping) => { const playlist = playlists[i]; const sidxKey = playlist.sidx.uri + '-' + byteRangeToString(playlist.sidx.byterange); - const sidxMatch = sidxMapping[sidxKey]; + const sidxMatch = sidxMapping[sidxKey] && sidxMapping[sidxKey].sidx; if (playlist.sidx && sidxMatch) { - addSegmentsToPlaylist(playlist, sidxMatch.sidx, playlist.sidx.resolvedUri); + addSegmentsToPlaylist(playlist, sidxMatch, playlist.sidx.resolvedUri); } }