Wavesurfer
Extends:
Draw a waveform for audio and video files in a video.js player.
Constructor Summary
| Public Constructor | ||
| public |
constructor(player: videojs.Player | Object, options: Object) The constructor function for the class. |
|
Member Summary
| Public Members | ||
| public |
backend: * |
|
| public |
debug: * |
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
surfer: * |
|
| public |
|
|
| public |
surferReady: * |
|
| public |
surferSeek: * |
|
| public |
|
|
| public |
|
|
| public |
|
|
| Private Members | ||
| private |
_formatTime: * |
|
Method Summary
| Public Methods | ||
| public |
destroy() Remove the player and waveform. |
|
| public |
Save waveform image as data URI. |
|
| public |
getCurrentTime(): float Get the current time (in seconds) of the stream during playback. |
|
| public |
getDuration(): float Get the duration of the stream in seconds. |
|
| public |
Indicates whether the plugin is destroyed or not. |
|
| public |
Start loading waveform data. |
|
| public |
Start loading waveform data. |
|
| public |
pause() Pauses playback or microphone visualization. |
|
| public |
play() Start/resume playback or microphone. |
|
| public |
setAudioOutput(deviceId: string) Change the audio output device. |
|
| public |
setFormatTime(customImplementation: function) Replaces the default |
|
| public |
Set the volume level. |
|
| Private Methods | ||
| private |
dispose() |
|
| private |
Player UI is ready: customize controls. |
|
| private |
Log message to console (if the debug option is enabled). |
|
| private |
Fired when the play toggle is clicked. |
|
| private |
Fired when the video.js player switches in or out of fullscreen mode. |
|
| private |
Fired when the volume in the video.js player changes. |
|
| private |
onWaveError(error: string) Waveform error. |
|
| private |
Fires when audio playback completed. |
|
| private |
onWaveProgress(time: number) Fires continuously during audio playback. |
|
| private |
Audio is loaded, decoded and the waveform is drawn. |
|
| private |
Fires during seeking of the waveform. |
|
| private |
parseOptions(surferOpts: Object): Object Initializes the waveform options. |
|
| private |
redrawWaveform(newWidth: number, newHeight: number) Redraw waveform. |
|
| private |
setCurrentTime(currentTime: number, duration: number) Updates the player's element displaying the current time. |
|
| private |
setDuration(duration: number) Updates the player's element displaying the duration time. |
|
| private |
setupPlaybackEvents(enable: boolean) Starts or stops listening to events related to audio-playback. |
|
Public Constructors
Public Members
public backend: * source
public debug: * source
public displayMilliseconds: * source
public originalHeight: * source
public originalWidth: * source
public surfer: * source
public surferProgress: * source
public surferReady: * source
public surferSeek: * source
public textTracksEnabled: * source
Private Members
private _formatTime: * source
Public Methods
public exportImage(format: string, quality: number, type: string): string | string[] | Promise source
Save waveform image as data URI.
The default format is 'image/png'. Other supported types are
'image/jpeg' and 'image/webp'.
Params:
| Name | Type | Attribute | Description |
| format | string |
|
A string indicating the image format.
The default format type is |
| quality | number |
|
A number between 0 and 1 indicating the image
quality to use for image formats that use lossy compression such as
|
| type | string | Image data type to return. Either 'blob' (default) or 'dataURL'. |
public getCurrentTime(): float source
Get the current time (in seconds) of the stream during playback.
Returns 0 if no stream is available (yet).
Return:
| float | Current time of the stream. |
public getDuration(): float source
Get the duration of the stream in seconds.
Returns 0 if no stream is available (yet).
Return:
| float | Duration of the stream. |
public load(url: string | blob | file, peaks: string | number[]) source
Start loading waveform data.
public loadPeaks(url: string | blob | file, peaks: string | number[]) source
Start loading waveform data.
public setAudioOutput(deviceId: string) source
Change the audio output device.
Params:
| Name | Type | Attribute | Description |
| deviceId | string | Id of audio output device. |
public setFormatTime(customImplementation: function) source
Replaces the default formatTime implementation with a custom implementation.
Params:
| Name | Type | Attribute | Description |
| customImplementation | function | A function which will be used in place
of the default |
public setVolume(volume: number) source
Set the volume level.
Params:
| Name | Type | Attribute | Description |
| volume | number | The new volume level. |
Private Methods
private dispose() source
private log(args: Array, logType: string) source
Log message to console (if the debug option is enabled).
private onScreenChange() source
Fired when the video.js player switches in or out of fullscreen mode.
private onWaveError(error: string) source
Waveform error.
Params:
| Name | Type | Attribute | Description |
| error | string | The wavesurfer error. |
private onWaveProgress(time: number) source
Fires continuously during audio playback.
Params:
| Name | Type | Attribute | Description |
| time | number | Current time/location of the playhead. |
private parseOptions(surferOpts: Object): Object source
Initializes the waveform options.
Params:
| Name | Type | Attribute | Description |
| surferOpts | Object | Plugin options. |
private setCurrentTime(currentTime: number, duration: number) source
Updates the player's element displaying the current time.
