Skip to content

Commit

Permalink
Fix for BUFFER_LOADED event never triggered when minBufferTime > stab…
Browse files Browse the repository at this point in the history
…leBufferTime (#3620)
  • Loading branch information
dsilhavy committed Apr 27, 2021
1 parent cab2d59 commit a6f8ba1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/streaming/controllers/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function BufferController(config) {
const streamInfo = config.streamInfo;
const type = config.type;
const settings = config.settings;
const mediaPlayerModel = config.mediaPlayerModel;

let instance,
logger,
Expand Down Expand Up @@ -658,15 +659,15 @@ function BufferController(config) {
// So, when in low latency mode, change dash.js behavior so it notifies a stall just when
// buffer reach 0 seconds
if (((!settings.get().streaming.lowLatencyEnabled && bufferLevel < settings.get().streaming.buffer.stallThreshold) || bufferLevel === 0) && !isBufferingCompleted) {
notifyBufferStateChanged(MetricsConstants.BUFFER_EMPTY);
_notifyBufferStateChanged(MetricsConstants.BUFFER_EMPTY);
} else {
if (isBufferingCompleted || bufferLevel >= streamInfo.manifestInfo.minBufferTime) {
notifyBufferStateChanged(MetricsConstants.BUFFER_LOADED);
if (isBufferingCompleted || bufferLevel >= mediaPlayerModel.getStableBufferTime()) {
_notifyBufferStateChanged(MetricsConstants.BUFFER_LOADED);
}
}
}

function notifyBufferStateChanged(state) {
function _notifyBufferStateChanged(state) {
if (bufferState === state ||
(state === MetricsConstants.BUFFER_EMPTY && playbackController.getTime() === 0) || // Don't trigger BUFFER_EMPTY if it's initial loading
(type === Constants.FRAGMENTED_TEXT && !textController.isTextEnabled())) {
Expand Down

0 comments on commit a6f8ba1

Please sign in to comment.