|
|
@@ -355,17 +355,15 @@ jsmpeg.prototype.collectIntraFrames = function() {
|
|
355
|
355
|
this.frameCount = frame;
|
|
356
|
356
|
};
|
|
357
|
357
|
|
|
358
|
|
-jsmpeg.prototype.seekToFrame = function(seekFrame, seekExact) {
|
|
359
|
|
- var target = null;
|
|
360
|
|
- for( var i = 1; i < this.intraFrames.length; i++ ) {
|
|
361
|
|
- if( this.intraFrames[i].frame > seekFrame ) {
|
|
362
|
|
- target = this.intraFrames[i-1];
|
|
363
|
|
- break;
|
|
364
|
|
- }
|
|
|
358
|
+jsmpeg.prototype.seekToFrame = function(seekFrame, seekExact) {
|
|
|
359
|
+ if( seekFrame < 0 || seekFrame >= this.frameCount || !this.intraFrames.length ) {
|
|
|
360
|
+ return false;
|
|
365
|
361
|
}
|
|
366
|
362
|
|
|
367
|
|
- if( !target ) {
|
|
368
|
|
- return false;
|
|
|
363
|
+ // Find the last intra frame before or equal to seek frame
|
|
|
364
|
+ var target = null;
|
|
|
365
|
+ for( var i = 0; i < this.intraFrames.length && this.intraFrames[i].frame <= seekFrame; i++ ) {
|
|
|
366
|
+ target = this.intraFrames[i];
|
|
369
|
367
|
}
|
|
370
|
368
|
|
|
371
|
369
|
this.buffer.index = target.index;
|