Skip to content

Commit

Permalink
fix: add id query to each dummy segment url to make them unique (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfrederiksen committed Nov 8, 2023
1 parent 669b498 commit 1ffdc0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion index.js
Expand Up @@ -17,6 +17,11 @@ const findNearestBw = (bw, array) => {

const NOT_MULTIVARIANT_ERROR_MSG = "Error: Source is Not a Multivariant Manifest";

let DUMMY_SUBTITLE_COUNT = 0;
const getDummySubtitleSegmentId = () => {
return DUMMY_SUBTITLE_COUNT++;
}

const findNearestGroupAndLang = (_group, _language, _playlist) => {
const groups = Object.keys(_playlist);
let group = groups[0]; // default
Expand Down Expand Up @@ -258,7 +263,7 @@ class HLSSpliceVod {
for (let index = 0; index < playlist.items.PlaylistItem.length; index++) {
if (playlist.items.PlaylistItem[index].get("duration")) {
duration += playlist.items.PlaylistItem[index].get("duration");
playlist.items.PlaylistItem[index].set("uri", this.dummySubtitleEndpoint);
playlist.items.PlaylistItem[index].set("uri", this.dummySubtitleEndpoint + `?id=${getDummySubtitleSegmentId()}`);
}
}
return [subtitleItems, duration];
Expand Down
4 changes: 2 additions & 2 deletions spec/hls_splice_subtitle_spec.js
Expand Up @@ -95,7 +95,7 @@ describe("HLSSpliceVod with subs", () => {
expect(substringsSubs[11]).toBe("#EXT-X-DISCONTINUITY");
expect(substringsSubs[12]).toBe("#EXT-X-CUE-OUT:DURATION=15");
expect(substringsSubs[13]).toBe("#EXTINF:3.0000,");
expect(substringsSubs[14]).toBe("/dummy");
expect(substringsSubs[14]).toContain("/dummy?id=");
expect(substringsSubs[24]).toBe("#EXT-X-CUE-IN");
done();
});
Expand Down Expand Up @@ -193,7 +193,7 @@ describe("HLSSpliceVod with subs", () => {
expect(substrings[7]).toBe("http://mock.com/ad/ad1_0_av.ts");
expect(substrings[16]).toBe("#EXT-X-DISCONTINUITY");

expect(substringsSubs[6]).toBe("/dummy");
expect(substringsSubs[6]).toContain("/dummy?id=");
expect(substringsSubs[15]).toBe("#EXT-X-DISCONTINUITY");
done();
});
Expand Down

0 comments on commit 1ffdc0b

Please sign in to comment.