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(HLS): Fix uncaught error in slow network scenario #7321

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(HLS): Fix uncaught error in slow network scenario
  • Loading branch information
avelad committed Sep 16, 2024
commit 45ca20f8f7d1443f8c8d4abf71b2dc84344f10a9
24 changes: 15 additions & 9 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1519,9 +1519,11 @@ shaka.media.StreamingEngine = class {
logPrefix, 'looking up segment from new stream endTime:', time);

const reverse = this.playerInterface_.getPlaybackRate() < 0;
mediaState.segmentIterator =
mediaState.stream.segmentIndex.getIteratorForTime(
time, /* allowNonIndepedent= */ false, reverse);
if (mediaState.stream.segmentIndex) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is null, is segmentIterator always null already?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

mediaState.segmentIterator =
mediaState.stream.segmentIndex.getIteratorForTime(
time, /* allowNonIndepedent= */ false, reverse);
}
const ref = mediaState.segmentIterator &&
mediaState.segmentIterator.next().value;
if (ref == null) {
Expand All @@ -1545,18 +1547,22 @@ shaka.media.StreamingEngine = class {
const reverse = this.playerInterface_.getPlaybackRate() < 0;
let ref = null;
if (inaccurateTolerance) {
mediaState.segmentIterator =
mediaState.stream.segmentIndex.getIteratorForTime(
lookupTime, /* allowNonIndepedent= */ false, reverse);
if (mediaState.stream.segmentIndex) {
mediaState.segmentIterator =
mediaState.stream.segmentIndex.getIteratorForTime(
lookupTime, /* allowNonIndepedent= */ false, reverse);
}
ref = mediaState.segmentIterator &&
mediaState.segmentIterator.next().value;
}
if (!ref) {
// If we can't find a valid segment with the drifted time, look for a
// segment with the presentation time.
mediaState.segmentIterator =
mediaState.stream.segmentIndex.getIteratorForTime(
presentationTime, /* allowNonIndepedent= */ false, reverse);
if (mediaState.stream.segmentIndex) {
mediaState.segmentIterator =
mediaState.stream.segmentIndex.getIteratorForTime(
presentationTime, /* allowNonIndepedent= */ false, reverse);
}
ref = mediaState.segmentIterator &&
mediaState.segmentIterator.next().value;
}
Expand Down
Loading