-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: Fix playRangeEnd for certain content #4068
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -361,6 +361,13 @@ shaka.media.PresentationTimeline = class { | |
getSegmentAvailabilityEnd() { | ||
if (!this.isLive() && !this.isInProgress()) { | ||
// It's a static manifest (can also be a dynamic->static conversion) | ||
if (this.maxSegmentEndTime_ && this.duration_) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we care about the possibility of If not, you don't need to check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, true. Fixed. |
||
// If we have both, use the min of the two. | ||
// Note that the playRangeEnd configuration changes this.duration_. | ||
// See https://github.com/shaka-project/shaka-player/issues/4026 | ||
return Math.min(this.maxSegmentEndTime_, this.duration_); | ||
} | ||
// If we don't have both, use whichever we do have. | ||
return this.maxSegmentEndTime_ || this.duration_; | ||
} | ||
// Can be either live or "in-progress recording" (live with known duration) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -690,6 +690,7 @@ describe('Player', () => { | |
player.configure({playRangeStart: 5, playRangeEnd: 10}); | ||
const timeline = new shaka.media.PresentationTimeline(300, 0); | ||
timeline.setStatic(true); | ||
timeline.setDuration(300); | ||
manifest = shaka.test.ManifestGenerator.generate((manifest) => { | ||
manifest.presentationTimeline = timeline; | ||
manifest.addVariant(0, (variant) => { | ||
|
@@ -703,6 +704,39 @@ describe('Player', () => { | |
expect(seekRange.end).toBe(10); | ||
}); | ||
|
||
// Test for https://github.com/shaka-project/shaka-player/issues/4026 | ||
it('configures play and seek range with notifySegments', async () => { | ||
player.configure({playRangeStart: 5, playRangeEnd: 10}); | ||
const timeline = new shaka.media.PresentationTimeline(300, 0); | ||
timeline.setStatic(true); | ||
timeline.setDuration(300); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit confusing how in this test, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's weird. What's really happening is that stream.useSegmentTemplate refers to timeline's duration to decide how many references to generate. Then player.load applies the config to the timeline, and sets the duration lower. What would be less confusing, I think, is if Timeline had a separate field for the playRangeEnd setting. But that would also require a lot more ifs or mins in Timeline, which could be confusing in a different way. |
||
manifest = shaka.test.ManifestGenerator.generate((manifest) => { | ||
manifest.presentationTimeline = timeline; | ||
manifest.addVariant(0, (variant) => { | ||
variant.addVideo(1, (stream) => { | ||
stream.useSegmentTemplate( | ||
'$Number$.mp4', /* segmentDuration= */ 10); | ||
}); | ||
}); | ||
}); | ||
goog.asserts.assert(manifest, 'manifest must be non-null'); | ||
|
||
// Explicitly notify the timeline of the segment references. | ||
const videoStream = manifest.variants[0].video; | ||
await videoStream.createSegmentIndex(); | ||
goog.asserts.assert(videoStream.segmentIndex, | ||
'SegmentIndex must be non-null'); | ||
const references = Array.from(videoStream.segmentIndex); | ||
goog.asserts.assert(references.length != 0, | ||
'Must have references for this test!'); | ||
timeline.notifySegments(references); | ||
|
||
await player.load(fakeManifestUri, 0, fakeMimeType); | ||
const seekRange = player.seekRange(); | ||
expect(seekRange.start).toBe(5); | ||
expect(seekRange.end).toBe(10); | ||
}); | ||
|
||
it('configures play and seek range after playback starts', async () => { | ||
const timeline = new shaka.media.PresentationTimeline(300, 0); | ||
timeline.setStatic(true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSDoc for the return value, above, says "Aways returns the presentation's duration for video-on-demand." That seems to be pretty out-of-date, now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks!