Skip to content

Commit

Permalink
fix: Remove preloaded segment when segment has network error (#6515)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Apr 30, 2024
1 parent 5f8e7fd commit 2f5062a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/media/segment_prefetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ shaka.media.SegmentPrefetch = class {
this.prefetchPosTime_ = 0;
}

/**
* Remove a reference of prefetched segment if already exists.
* @param {!shaka.media.SegmentReference} reference
* @public
*/
removeReference(reference) {
this.abortPrefetchedSegment_(reference);
}

/**
* @param {number} time
* @param {boolean=} clearInitSegments
Expand Down
5 changes: 5 additions & 0 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,11 @@ shaka.media.StreamingEngine = class {
error.code);
mediaState.hasError = true;

if (error.category == shaka.util.Error.Category.NETWORK &&
mediaState.segmentPrefetch) {
mediaState.segmentPrefetch.removeReference(reference);
}

error.severity = shaka.util.Error.Severity.CRITICAL;
await this.handleStreamingError_(mediaState, error);
}
Expand Down

0 comments on commit 2f5062a

Please sign in to comment.