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

Require min cue duration of 0.25 #2951

Merged
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
13 changes: 7 additions & 6 deletions src/controller/id3-track-controller.js
Expand Up @@ -8,6 +8,8 @@ import ID3 from '../demux/id3';
import { logger } from '../utils/logger';
import { sendAddTrackEvent, clearCurrentCues, getClosestCue } from '../utils/texttrack-utils';

const MIN_CUE_DURATION = 0.25;

class ID3TrackController extends EventHandler {
constructor (hls) {
super(hls,
Expand Down Expand Up @@ -76,12 +78,11 @@ class ID3TrackController extends EventHandler {
if (!endTime) {
endTime = fragment.start + fragment.duration;
}
if (startTime === endTime) {
// Give a slight bump to the endTime if it's equal to startTime to avoid a SyntaxError in IE
endTime += 0.0001;
} else if (startTime > endTime) {
logger.warn('detected an id3 sample with endTime < startTime, adjusting endTime to (startTime + 0.25)');
endTime = startTime + 0.25;

const timeDiff = endTime - startTime;
if (timeDiff < MIN_CUE_DURATION) {
logger.warn(`detected an id3 sample with a duration of ${timeDiff}s. Adjusting to provide a duration of ${MIN_CUE_DURATION}`);
endTime += MIN_CUE_DURATION - timeDiff;
}

for (let j = 0; j < frames.length; j++) {
Expand Down