diff --git a/src/isofile.js b/src/isofile.js index a56b4786..cae2d0f7 100644 --- a/src/isofile.js +++ b/src/isofile.js @@ -449,9 +449,11 @@ ISOFile.prototype.processSamples = function(last) { /* The fragment could not be created because the media data is not there (not downloaded), wait for it */ break; } + var nextSample = trak.samples[trak.nextSample]; + var emitForRapBoundary = fragTrak.rapAlignement && nextSample && nextSample.is_sync; /* A fragment is created by sample, but the segment is the accumulation in the buffer of these fragments. It is flushed only as requested by the application (nb_samples) to avoid too many callbacks */ - if (trak.nextSample % fragTrak.nb_samples === 0 || (last || trak.nextSample >= trak.samples.length)) { + if (emitForRapBoundary || trak.nextSample % fragTrak.nb_samples === 0 || (last || trak.nextSample >= trak.samples.length)) { Log.info("ISOFile", "Sending fragmented data on track #"+fragTrak.id+" for samples ["+Math.max(0,trak.nextSample-fragTrak.nb_samples)+","+(trak.nextSample-1)+"]"); Log.info("ISOFile", "Sample data size in memory: "+this.getAllocatedSampleDataSize()); if (this.onSegment) {