From 2a5929cc738841a629a7abbc83efb241caf65800 Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Wed, 3 Mar 2021 16:38:50 -0500 Subject: [PATCH] cr --- src/dash-playlist-loader.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/dash-playlist-loader.js b/src/dash-playlist-loader.js index 53f52c9ef..72f210660 100644 --- a/src/dash-playlist-loader.js +++ b/src/dash-playlist-loader.js @@ -727,15 +727,12 @@ export default class DashPlaylistLoader extends EventTarget { mpl.createMupOnMedia_ = null; } - // clear any pending timeouts, master was just updated - // so if minimumUpdatePeriodTimeout_ is still valid - window.clearTimeout(mpl.minimumUpdatePeriodTimeout_); - mpl.minimumUpdatePeriodTimeout_ = null; - mpl.createMUPTimeout_(); - } + // clear any pending timeouts + if (mpl.minimumUpdatePeriodTimeout_) { + window.clearTimeout(mpl.minimumUpdatePeriodTimeout_); + mpl.minimumUpdatePeriodTimeout_ = null; + } - createMUPTimeout_() { - const mpl = this.masterPlaylistLoader_; let mup = mpl.master && mpl.master.minimumUpdatePeriod; // If the minimumUpdatePeriod has a value of 0, that indicates that the current @@ -751,21 +748,23 @@ export default class DashPlaylistLoader extends EventTarget { } } - // if minimumUpdatePeriod is invalid or <= zero skip creating a timeout + // if minimumUpdatePeriod is invalid or <= zero, which + // can happen when a live video becomes VOD. skip timeout + // creation. if (typeof mup !== 'number' || mup <= 0) { return; } + this.createMUPTimeout_(mup); + } + + createMUPTimeout_(mup) { + const mpl = this.masterPlaylistLoader_; + mpl.minimumUpdatePeriodTimeout_ = window.setTimeout(() => { mpl.minimumUpdatePeriodTimeout_ = null; - mpl.createMUPTimeout_(); - - // if a minimumUpdatePeriodTimeout_ was created again - // then the minimumUpdatePeriod was valid - // trigger minimumUpdatePeriod - if (mpl.minimumUpdatePeriodTimeout_) { - mpl.trigger('minimumUpdatePeriod'); - } + mpl.trigger('minimumUpdatePeriod'); + mpl.createMUPTimeout_(mup); }, mup); }