From 9ac6ef8613b31ce3ad7678733c8e860136779b31 Mon Sep 17 00:00:00 2001 From: Alex Barstow Date: Thu, 24 Sep 2020 12:04:00 -0400 Subject: [PATCH] fix case when mup is 0 on first mpd load --- src/dash-playlist-loader.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/dash-playlist-loader.js b/src/dash-playlist-loader.js index 92a6d571f..6fea8c125 100644 --- a/src/dash-playlist-loader.js +++ b/src/dash-playlist-loader.js @@ -653,15 +653,31 @@ export default class DashPlaylistLoader extends EventTarget { // Clear existing timeout window.clearTimeout(this.minimumUpdatePeriodTimeout_); - const minimumUpdatePeriod = this.master && this.master.minimumUpdatePeriod; - - if (minimumUpdatePeriod >= 0) { + const createMUPTimeout = (mup) => { this.minimumUpdatePeriodTimeout_ = window.setTimeout(() => { this.trigger('minimumUpdatePeriod'); - // We use the target duration here because a minimumUpdatePeriod value of 0 - // indicates that the current MPD has no future validity, so a new one will - // need to be acquired when new media segments are to be made available - }, minimumUpdatePeriod || this.media().targetDuration * 1000); + }, mup); + }; + + const minimumUpdatePeriod = this.master && this.master.minimumUpdatePeriod; + + if (minimumUpdatePeriod > 0) { + createMUPTimeout(minimumUpdatePeriod); + + // If the minimumUpdatePeriod has a value of 0, that indicates that the current + // MPD has no future validity, so a new one will need to be acquired when new + // media segments are to be made available. Thus, we use the target duration + // in this case + } else if (minimumUpdatePeriod === 0) { + // If we haven't yet selected a playlist, wait until then so we know the + // target duration + if (!this.media()) { + this.one('loadedplaylist', () => { + createMUPTimeout(this.media().targetDuration * 1000); + }); + } else { + createMUPTimeout(this.media().targetDuration * 1000); + } } }