Skip to content

Commit

Permalink
fix: Adjust timing of mediaqualitychanged event when safe margin is s…
Browse files Browse the repository at this point in the history
…et (#7114)
  • Loading branch information
tykus160 authored Aug 20, 2024
1 parent a1d3927 commit f6ac236
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,8 @@ shaka.media.StreamingEngine = class {
const MimeUtils = shaka.util.MimeUtils;
const StreamingEngine = shaka.media.StreamingEngine;
const logPrefix = StreamingEngine.logPrefix_(mediaState);
const nullLastReferences = mediaState.lastSegmentReference == null &&
mediaState.lastInitSegmentReference == null;

/** @type {!Array.<!Promise>} */
const operations = [];
Expand Down Expand Up @@ -2120,8 +2122,19 @@ shaka.media.StreamingEngine = class {
throw error;
}
};
let initSegmentTime = reference.startTime;
if (nullLastReferences) {
const bufferEnd =
this.playerInterface_.mediaSourceEngine.bufferEnd(mediaState.type);
if (bufferEnd != null) {
// Adjust init segment appendance time if we have something in
// a buffer, i.e. due to running switchVariant() with non zero
// safe margin value.
initSegmentTime = bufferEnd;
}
}
this.playerInterface_.onInitSegmentAppended(
reference.startTime, reference.initSegmentReference);
initSegmentTime, reference.initSegmentReference);
operations.push(append());
}
}
Expand Down

0 comments on commit f6ac236

Please sign in to comment.