diff --git a/lib/mss/mss_parser.js b/lib/mss/mss_parser.js index ecf6f4ad94..dae8880d6c 100644 --- a/lib/mss/mss_parser.js +++ b/lib/mss/mss_parser.js @@ -966,6 +966,12 @@ shaka.mss.MssParser = class { let startTime = t != null ? t : lastEndTime; let repeat = r || 0; + // Unlike in DASH, in MSS r does not start counting repetitions at 0 but + // at 1, to maintain the code equivalent to DASH if r exists we + // subtract 1. + if (repeat) { + repeat--; + } if (repeat < 0) { if (next) { const nextStartTime = diff --git a/test/mss/mss_parser_unit.js b/test/mss/mss_parser_unit.js index 3bb3f4d4e1..071bba0d1a 100644 --- a/test/mss/mss_parser_unit.js +++ b/test/mss/mss_parser_unit.js @@ -257,6 +257,27 @@ describe('MssParser Manifest', () => { expect(stream).toBeUndefined(); }); + it('support for repetitions', async () => { + const manifestText = [ + '', + ' ', + ' ', + ' ', + ' ', + '', + ].join('\n'); + + fakeNetEngine.setResponseText('dummy://foo', manifestText); + + const manifest = await parser.start('dummy://foo', playerInterface); + expect(manifest.variants.length).toBe(1); + await manifest.variants[0].audio.createSegmentIndex(); + const segmentIndex = manifest.variants[0].audio.segmentIndex; + expect(segmentIndex.getNumReferences()).toBe(12); + }); + it('generate a fake init segment', async () => { const manifestText = [ '',