Skip to content

Commit

Permalink
Fix alt-audio video-dev#2006 (video-dev#2067)
Browse files Browse the repository at this point in the history
* Compute live start position for alt audio streams
  • Loading branch information
JuliusThms authored and John Bartos committed Jun 5, 2019
1 parent 1ea14ad commit cf801df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,12 @@ class AudioStreamController extends BaseStreamController {
logger.log(`start time offset found in playlist, adjust startPosition to ${startTimeOffset}`);
this.startPosition = startTimeOffset;
} else {
this.startPosition = 0;
if (newDetails.live) {
this.startPosition = this.computeLivePosition(sliding, newDetails);
logger.log(`compute startPosition for audio-track to ${this.startPosition}`);
} else {
this.startPosition = 0;
}
}
}
this.nextLoadPosition = this.startPosition;
Expand Down
5 changes: 5 additions & 0 deletions src/controller/base-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,9 @@ export default class BaseStreamController extends TaskLoop {
this.state = State.STOPPED;
this.fragmentTracker = null;
}

computeLivePosition (sliding, levelDetails) {
let targetLatency = this.config.liveSyncDuration !== undefined ? this.config.liveSyncDuration : this.config.liveSyncDurationCount * levelDetails.targetduration;
return sliding + Math.max(0, levelDetails.totalduration - targetLatency);
}
}
6 changes: 0 additions & 6 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1292,12 +1292,6 @@ class StreamController extends BaseStreamController {
swapAudioCodec () {
this.audioCodecSwap = !this.audioCodecSwap;
}

computeLivePosition (sliding, levelDetails) {
let targetLatency = this.config.liveSyncDuration !== undefined ? this.config.liveSyncDuration : this.config.liveSyncDurationCount * levelDetails.targetduration;
return sliding + Math.max(0, levelDetails.totalduration - targetLatency);
}

/**
* Seeks to the set startPosition if not equal to the mediaElement's current time.
* @private
Expand Down

0 comments on commit cf801df

Please sign in to comment.