Skip to content

Commit

Permalink
fix: MPD not refreshed if minimumUpdatePeriod is 0 (#954)
Browse files Browse the repository at this point in the history
This fixes a bug caused by an oversight in #942. If the MPD@minimumUpdatePeriod is 0 in the first dynamic MPD we load, we should use the media's target duration as the MPD refresh interval, however we need to wait until a playlist has been selected before we can know DashPlaylistLoader.media().targetDuration, otherwise we get a TypeError.
  • Loading branch information
alex-barstow authored Sep 24, 2020
1 parent 8648e76 commit 3a0682f
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/dash-playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 3a0682f

Please sign in to comment.