Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Stop Using Previous VOD to Set timeOffset #119

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1930,10 +1930,7 @@ class HLSVod {
this.segments[destBw].push(q);
}
}
const lastSeg = this.segments[sourceBw][this.segments[sourceBw].length - 1];
if (this.timeOffset !== null && lastSeg && lastSeg.timelinePosition) {
this.timeOffset = lastSeg.timelinePosition + lastSeg.duration * 1000;
}

this.segments[destBw].push({
discontinuity: true,
daterange: this.rangeMetadata ? this.rangeMetadata : null,
Expand Down
14 changes: 8 additions & 6 deletions spec/hlsvod_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,18 +686,19 @@ describe("HLSVod with timeline", () => {


it("can handle vod after another vod", (done) => {
const VOD_LENGTH_MS = 2646000 + 6266;
const now = Date.now();
mockVod = new HLSVod("http://mock.com/mock.m3u8", [], now);
mockVod2 = new HLSVod("http://mock.com/mock2.m3u8", [], now + 1);
mockVod2 = new HLSVod("http://mock.com/mock2.m3u8", [], now + VOD_LENGTH_MS);
mockVod
.load(mockMasterManifest, mockMediaManifest)
.then(() => {
return mockVod2.loadAfter(mockVod, mockMasterManifest, mockMediaManifest);
})
.then(() => {
const seqSegments = mockVod2.getLiveMediaSequenceSegments(0);
expect(seqSegments["2497000"][4].timelinePosition).toEqual(now + 2646 * 1000);
expect(seqSegments["2497000"][6].timelinePosition).toEqual(now + 2646 * 1000 + 6266);
expect(seqSegments["2497000"][4].timelinePosition).toEqual(now + VOD_LENGTH_MS - 6266);
expect(seqSegments["2497000"][6].timelinePosition).toEqual(now + VOD_LENGTH_MS);
done();
});
});
Expand Down Expand Up @@ -755,17 +756,18 @@ describe("HLSVod with timeline", () => {
},
];
const now = Date.now();
const VOD_LENGTH_MS = 2646000 + 6266;
mockVod = new HLSVod("http://mock.com/mock.m3u8", [], now);
mockVod2 = new HLSVod("http://mock.com/mock2.m3u8", splices, now + 1);
mockVod2 = new HLSVod("http://mock.com/mock2.m3u8", splices, now + VOD_LENGTH_MS);
mockVod
.load(mockMasterManifest, mockMediaManifest)
.then(() => {
return mockVod2.loadAfter(mockVod, mockMasterManifest, mockMediaManifest);
})
.then(() => {
const seqSegments = mockVod2.getLiveMediaSequenceSegments(0);
expect(seqSegments["2497000"][4].timelinePosition).toEqual(now + 2646 * 1000);
expect(seqSegments["2497000"][6].timelinePosition).toEqual(now + 2646 * 1000 + 6266);
expect(seqSegments["2497000"][4].timelinePosition).toEqual(now + VOD_LENGTH_MS - 6266);
expect(seqSegments["2497000"][6].timelinePosition).toEqual(now + VOD_LENGTH_MS);
done();
});
});
Expand Down
Loading