Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix application of EXT-X-START: TIME-OFFSET in live after refresh #3962

Merged
merged 1 commit into from May 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/controller/base-stream-controller.ts
Expand Up @@ -1122,20 +1122,25 @@ export default class BaseStreamController
protected setStartPosition(details: LevelDetails, sliding: number) {
// compute start position if set to -1. use it straight away if value is defined
let startPosition = this.startPosition;
if (this.startPosition === -1 || this.lastCurrentTime === -1) {
if (startPosition < sliding) {
startPosition = -1;
}
if (startPosition === -1 || this.lastCurrentTime === -1) {
// first, check if start time offset has been set in playlist, if yes, use this value
let startTimeOffset = details.startTimeOffset!;
const startTimeOffset = details.startTimeOffset!;
if (Number.isFinite(startTimeOffset)) {
startPosition = sliding + startTimeOffset;
if (startTimeOffset < 0) {
this.log(
`Negative start time offset ${startTimeOffset}, count from end of last fragment`
);
startTimeOffset = sliding + details.totalduration + startTimeOffset;
startPosition += details.totalduration;
}
startPosition = Math.min(
Math.max(sliding, startPosition),
sliding + details.totalduration
);
this.log(
`Start time offset found in playlist, adjust startPosition to ${startTimeOffset}`
`Start time offset ${startTimeOffset} found in playlist, adjust startPosition to ${startPosition}`
);
this.startPosition = startPosition = startTimeOffset;
this.startPosition = startPosition;
} else if (details.live) {
// Leave this.startPosition at -1, so that we can use `getInitialLiveFragment` logic when startPosition has
// not been specified via the config or an as an argument to startLoad (#3736).
Expand Down