Просмотр исходного кода

Added onfinished callback; close #7

Dominic Szablewski 12 лет назад
Родитель
Сommit
43c8a3ddc4
1 измененных файлов: 5 добавлений и 0 удалений
  1. 5 0
      jsmpg.js

+ 5 - 0
jsmpg.js Просмотреть файл

@@ -32,6 +32,7 @@ var jsmpeg = window.jsmpeg = function( url, opts ) {
32 32
 	this.loop = !!opts.loop;
33 33
 	this.externalLoadCallback = opts.onload || null;
34 34
 	this.externalDecodeCallback = opts.ondecodeframe || null;
35
+	this.externalFinishedCallback = opts.onfinished || null;
35 36
 	this.bwFilter = opts.bwFilter || false;
36 37
 
37 38
 	this.customIntraQuantMatrix = new Uint8Array(64);
@@ -388,6 +389,10 @@ jsmpeg.prototype.nextFrame = function() {
388 389
 		else if( code == BitReader.NOT_FOUND ) {
389 390
 			this.stop(); // Jump back to the beginning
390 391
 
392
+			if( this.this.externalFinishedCallback ) {
393
+				this.externalFinishedCallback(this);
394
+			}
395
+
391 396
 			// Only loop if we found a sequence header
392 397
 			if( this.loop && this.sequenceStarted ) {
393 398
 				this.play();