AudioRecorder
Audio recording component.
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) ITSLanguage AudioRecorder. |
Member Summary
Public Members | ||
public |
|
|
public |
audioContext: * |
|
public |
|
|
public |
micInput: * |
|
public |
|
Private Members | ||
private |
_emitter: * |
|
private |
|
|
private |
_settings: * |
|
private |
_stopwatch: * |
Method Summary
Public Methods | ||
public |
addEventListener(name: string, handler: Function) Add an event listener. |
|
public |
bindStopwatch(tickCb: Function): Stopwatch Bind a stopwatch to sync with the playing and stopping functionality of the recorder. |
|
public |
Get the audio context or create one. |
|
public |
Get the recorded audio specifications. |
|
public |
Check if the user has already given permission to access the microphone. |
|
public |
Check if there is a recording in progress. |
|
public |
Start recording microphone input until stopped. |
|
public |
Turn off all event listeners for this recorder. |
|
public |
removeEventListener(name: string, handler: Function) Remove an event listener of the recorder. |
|
public |
Request microphone access. |
|
public |
Set a new recording session id. |
|
public |
Stop recording microphone input. |
|
public |
streamCallback(chunk: ArrayBuffer) Called when a chunk of audio becomes available. |
|
public |
Toggle audio playback. |
Private Methods | ||
private |
_getBestRecorder(micInputGain: GainNode): * Get a recorder object that performs audio compression, when available. |
|
private |
Logs browser compatibility for audio recording. |
|
private |
Throw an error if the user is not yet logged in. |
|
private |
_startUserMedia(stream: MediaStream): * Audio access was granted, start analysing. |
|
private |
Fire an event. |
Public Constructors
Public Members
public activeRecordingId: * source
public audioContext: * source
public micInput: * source
Private Members
private _emitter: * source
private _recorder: WebAudioRecorder | MediaRecorder source
private _settings: * source
private _stopwatch: * source
Public Methods
public addEventListener(name: string, handler: Function) source
Add an event listener. Listens to events emitted from the recorder.
public bindStopwatch(tickCb: Function): Stopwatch source
Bind a stopwatch to sync with the playing and stopping functionality of the recorder.
Params:
Name | Type | Attribute | Description |
tickCb | Function | Callback to invoke on every tick. A tick occurs once every 100 ms. |
Throw:
If _tickCb is null. |
public hasUserMediaApproval(): boolean source
Check if the user has already given permission to access the microphone.
public record(cb: Function, disableDelay: boolean): * source
Start recording microphone input until stopped. By default the actual recording will start a small delay of 100ms. Set disableDelay to true to disable this delay.
Return:
* |
Emit:
Event |
'recording' With arguments: [recording ID]. |
public removeEventListener(name: string, handler: Function) source
Remove an event listener of the recorder.
public requestUserMedia(): Promise source
Request microphone access.
Calling this function may result in thrown exceptions when browser doesn't support provide live audio input.
Return:
Promise | A promise that resolves a MediaStream object. If the user denies permission, or matching media is not available, then the promise is rejected with PermissionDeniedError or NotFoundError respectively. |
Throw:
If no live audio input is available or permitted. |
public startRecordingSession(id: number): number source
Set a new recording session id.
Params:
Name | Type | Attribute | Description |
id | number | When defined, stick this id to the recorded blob. |
public stop(forced: boolean) source
Stop recording microphone input.
Params:
Name | Type | Attribute | Description |
forced | boolean |
|
Set whether to force the microphone to stop recording or let it end normally. |
Emit:
Event |
'recorded' With arguments: [recording ID, audio Blob, forced]. |
public streamCallback(chunk: ArrayBuffer) source
Called when a chunk of audio becomes available.
Params:
Name | Type | Attribute | Description |
chunk | ArrayBuffer | A chunk of audio (Int16 formatted). |
public toggleRecording() source
Toggle audio playback. Switch from playing to paused state and back.
Private Methods
private _getBestRecorder(micInputGain: GainNode): * source
Get a recorder object that performs audio compression, when available.
Using the Media Stream Recording API for recording is the prefered solution. It allows recording compressed audio which makes it quicker to submit. If not available, use a default createScriptProcessor is used.
Params:
Name | Type | Attribute | Description |
micInputGain | GainNode | The GainNode to analyze. |
Return:
* |
private _recordingCompatibility() source
Logs browser compatibility for audio recording. In case of compatibility issues, an error is thrown.
private _startUserMedia(stream: MediaStream): * source
Audio access was granted, start analysing.
Params:
Name | Type | Attribute | Description |
stream | MediaStream | Media Stream. |
Return:
* |