Skip to content

Commit

Permalink
Adjust id3 samples with PTS greater than fragment's endPTS to avoid S…
Browse files Browse the repository at this point in the history
…yntaxErrors on IE & Edge

* If the cue startTime < endTime, set startTime to endTime + 0.25
  • Loading branch information
ashCode0 authored and John Bartos committed May 7, 2019
1 parent f4792b4 commit ff9c844
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/controller/id3-track-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Event from '../events';
import EventHandler from '../event-handler';
import ID3 from '../demux/id3';
import { logger } from '../utils/logger';
import { sendAddTrackEvent, clearCurrentCues } from '../utils/texttrack-utils';

class ID3TrackController extends EventHandler {
Expand Down Expand Up @@ -70,9 +71,12 @@ class ID3TrackController extends EventHandler {
const startTime = samples[i].pts;
let endTime = i < samples.length - 1 ? samples[i + 1].pts : fragment.endPTS;

// Give a slight bump to the endTime if it's equal to startTime to avoid a SyntaxError in IE
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;
}

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

0 comments on commit ff9c844

Please sign in to comment.