From 951aaea8225b75beea5d2699b0213bb1a950c679 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 6547f985c2..f5c0803b0a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -66,6 +66,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 2c0f1a0823..cc999ea69a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -99,6 +99,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 db83cf07df..03d505b09b 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -980,7 +980,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'); @@ -1010,8 +1014,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) {