Skip to content

Commit

Permalink
fix: set default segments count if no duration
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed Apr 27, 2024
1 parent 06f8ff7 commit 41525f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ const parseSegmentsFromTemplate = (
const startNumber = Number(segmentTemplate.get('startNumber') || 1);
const segmentTimeline = segmentTemplate.get('SegmentTimeline');
resolveSegmentTemplateUrls(segmentTemplate, baseUrl, manifestUrl);
if (!duration) throw new Error('Duration of the Period was unable to be determined.');
const segmentDuration = parseFloat(segmentTemplate.get('duration'));
const segmentTimescale = parseFloat(segmentTemplate.get('timescale') || 1);
const segmentsCount = Math.ceil(duration / (segmentDuration / segmentTimescale));
// TODO: Support live manifests with type=dynamic
const DEFAULT_SEGMENTS_COUNT = 35;
// if (!duration) throw new Error('Duration of the Period was unable to be determined.');
const segmentsCount = duration
? Math.ceil(duration / (segmentDuration / segmentTimescale))
: DEFAULT_SEGMENTS_COUNT;
const bandwidth = representation.get('bandwidth');
const id = representation.get('id');
const segments = [];
Expand Down

0 comments on commit 41525f7

Please sign in to comment.