Skip to content

Commit

Permalink
Added onfinished callback; close phoboslab#7
Browse files Browse the repository at this point in the history
  • Loading branch information
phoboslab committed Feb 13, 2014
1 parent 3dbbcb9 commit 43c8a3d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jsmpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var jsmpeg = window.jsmpeg = function( url, opts ) {
this.loop = !!opts.loop;
this.externalLoadCallback = opts.onload || null;
this.externalDecodeCallback = opts.ondecodeframe || null;
this.externalFinishedCallback = opts.onfinished || null;
this.bwFilter = opts.bwFilter || false;

this.customIntraQuantMatrix = new Uint8Array(64);
Expand Down Expand Up @@ -388,6 +389,10 @@ jsmpeg.prototype.nextFrame = function() {
else if( code == BitReader.NOT_FOUND ) {
this.stop(); // Jump back to the beginning

if( this.this.externalFinishedCallback ) {
this.externalFinishedCallback(this);
}

// Only loop if we found a sequence header
if( this.loop && this.sequenceStarted ) {
this.play();
Expand Down

0 comments on commit 43c8a3d

Please sign in to comment.