From 2868e122eb5bc2db57ca96c429ad8178f7f5e3f4 Mon Sep 17 00:00:00 2001 From: PAPICO Date: Tue, 4 Oct 2022 07:51:02 +0900 Subject: [PATCH] fix: Fix hang when seeking to the last segment (#4537) The fetchAndAppend_ function was not running on the last segment. --- AUTHORS | 2 ++ CONTRIBUTORS | 1 + lib/media/streaming_engine.js | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 89c2fa62fb..cfc62d4f2e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -68,6 +68,8 @@ Rostislav Hejduk SameGoal Inc. <*@samegoal.com> Sanborn Hilland Sander Saares +Sanil Raut +Seongryun Jo Swank Motion Pictures Inc. <*@swankmp.com> TalkTalk Plc <*@talktalkplc.com> Tatsiana Gelahova diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4b8390e923..e7a03e6a5f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -102,6 +102,7 @@ Sander Saares Sandra Lokshina Satheesh Velmurugan Semih Gokceoglu +Seongryun Jo Seth Madison Tatsiana Gelahova Theodore Abshire diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index e5e3d1d6db..24e309cfc2 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -991,7 +991,11 @@ shaka.media.StreamingEngine = class { const timeUntilEnd = this.manifest_.presentationTimeline.getDuration() - timeNeeded; const oneMicrosecond = 1e-6; - if (timeUntilEnd < oneMicrosecond) { + + const bufferEnd = + this.playerInterface_.mediaSourceEngine.bufferEnd(mediaState.type); + + if (timeUntilEnd < oneMicrosecond && !!bufferEnd) { // We shouldn't rebuffer if the playhead is close to the end of the // presentation. shaka.log.debug(logPrefix, 'buffered to end of presentation'); @@ -1021,8 +1025,6 @@ shaka.media.StreamingEngine = class { return this.config_.updateIntervalSeconds / 2; } - const bufferEnd = - this.playerInterface_.mediaSourceEngine.bufferEnd(mediaState.type); const reference = this.getSegmentReferenceNeeded_( mediaState, presentationTime, bufferEnd); if (!reference) {