Skip to content

Commit

Permalink
audio-stream-controller: dont switch to ENDED if we just got done loa…
Browse files Browse the repository at this point in the history
…ding the final fragment and there is no other buffered range after

related to video-dev#1444
  • Loading branch information
mangui committed Nov 28, 2017
1 parent d6f7001 commit aca50e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ class AudioStreamController extends EventHandler {
break;
}

// we just got done loading the final fragment, check if we need to finalize media stream
if (!audioSwitch && !trackDetails.live && fragPrevious && fragPrevious.sn === trackDetails.endSN) {
// check if we need to finalize media stream
// we just got done loading the final fragment and there is no other buffered range after ...
// rationale is that in case there are any buffered ranges after, it means that there are unbuffered portion in between
// so we should not switch to ENDED in that case, to be able to buffer them
if (!audioSwitch && !trackDetails.live && fragPrevious && fragPrevious.sn === trackDetails.endSN && !bufferInfo.nextStart) {
// if we are not seeking or if we are seeking but everything (almost) til the end is buffered, let's signal eos
// we don't compare exactly media.duration === bufferInfo.end as there could be some subtle media duration difference when switching
// between different renditions. using half frag duration should help cope with these cases.
Expand Down

0 comments on commit aca50e6

Please sign in to comment.