Skip to content

Commit

Permalink
Merge pull request #2194 from Orange-OpenSource/startStreamWithOffsetBug
Browse files Browse the repository at this point in the history
Bug fix about start time
  • Loading branch information
epiclabsDASH committed Sep 28, 2017
2 parents 51ec636 + a37527f commit 2e801f5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/streaming/controllers/PlaybackController.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ function PlaybackController() {
return false;
}
function onBytesAppended(e) {
let earliestTime,
initialStartTime;
let ranges = e.bufferedRanges;
if (!ranges || !ranges.length) return;
if (commonEarliestTime[streamInfo.id] === false) {
Expand Down Expand Up @@ -472,19 +474,20 @@ function PlaybackController() {
const hasAudioTrack = streamController.isAudioTrackPresent();

if (hasAudioTrack && hasVideoTrack) {
//current stream has audio and video contents
if (!isNaN(commonEarliestTime[streamInfo.id].audio) && !isNaN(commonEarliestTime[streamInfo.id].video)) {

let earliestTime;
let ranges;
initialStartTime = getStreamStartTime(false);

if (commonEarliestTime[streamInfo.id].audio < commonEarliestTime[streamInfo.id].video) {
// common earliest is video time
// check buffered audio range has video time, if ok, we seek, otherwise, we wait some other data
earliestTime = commonEarliestTime[streamInfo.id].video;
earliestTime = commonEarliestTime[streamInfo.id].video > initialStartTime ? commonEarliestTime[streamInfo.id].video : initialStartTime;
ranges = bufferedRange[streamInfo.id].audio;
} else {
// common earliest is audio time
// check buffered video range has audio time, if ok, we seek, otherwise, we wait some other data
earliestTime = commonEarliestTime[streamInfo.id].audio;
earliestTime = commonEarliestTime[streamInfo.id].audio > initialStartTime ? commonEarliestTime[streamInfo.id].audio : initialStartTime;
ranges = bufferedRange[streamInfo.id].video;
}
if (checkTimeInRanges(earliestTime, ranges)) {
Expand All @@ -493,8 +496,10 @@ function PlaybackController() {
}
}
} else {
//current stream has only audio or only video content
if (commonEarliestTime[streamInfo.id][type]) {
seek(commonEarliestTime[streamInfo.id][type]);
earliestTime = commonEarliestTime[streamInfo.id][type] > initialStartTime ? commonEarliestTime[streamInfo.id][type] : initialStartTime;
seek(earliestTime);
commonEarliestTime[streamInfo.id] = false;
}
}
Expand Down

0 comments on commit 2e801f5

Please sign in to comment.