Skip to content

Commit

Permalink
recordingTime is duration
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rudmin committed May 3, 2015
1 parent 66eaf31 commit 1ae28b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The Opus encoder will not work if the value is not 8000, 12000, 16000, 24000 or

rec.addEventListener( type, listener[, useCapture] )

**addEventListener** will add an event listener to the event target. Available events are "recordingProgress", "streamError", "streamReady", dataAvailable", "start", "pause", "resume" and "stop".
**addEventListener** will add an event listener to the event target. Available events are "duration", "streamError", "streamReady", dataAvailable", "start", "pause", "resume" and "stop".

rec.setMonitorGain( gain )

Expand Down
2 changes: 1 addition & 1 deletion example.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h2>Log</h2>
pause.disabled = stopButton.disabled = false;
});

recorder.addEventListener( "recordingProgress", function(e){
recorder.addEventListener( "duration", function(e){
screenLogger('Recorded ' + e.detail + ' seconds');
});

Expand Down
8 changes: 4 additions & 4 deletions recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ Recorder.prototype.recordBuffers = function( inputBuffer ){
}

this.worker.postMessage({ command: "recordBuffers", buffers: buffers });
this.recordingTime += inputBuffer.duration;
this.eventTarget.dispatchEvent( new CustomEvent( 'recordingProgress', { "detail": this.recordingTime } ) );
this.duration += inputBuffer.duration;
this.eventTarget.dispatchEvent( new CustomEvent( 'duration', { "detail": this.duration } ) );
}
};

Expand Down Expand Up @@ -152,12 +152,12 @@ Recorder.prototype.start = function(){
});

this.state = "recording";
this.recordingTime = 0;
this.duration = 0;
this.monitorNode.connect( this.audioContext.destination );
this.scriptProcessorNode.connect( this.audioContext.destination );
this.recordBuffers = function(){ delete this.recordBuffers }; // First buffer can contain old data
this.eventTarget.dispatchEvent( new Event( 'start' ) );
this.eventTarget.dispatchEvent( new CustomEvent( 'recordingProgress', { "detail": this.recordingTime } ) );
this.eventTarget.dispatchEvent( new CustomEvent( 'duration', { "detail": this.duration } ) );
}
};

Expand Down

0 comments on commit 1ae28b6

Please sign in to comment.