Home Reference Source
import TimelinePlugin from 'wavesurfer.js/src/plugin/timeline.js'
public class | source

TimelinePlugin

Extends:

Observer → TimelinePlugin

Implements:

Adds a timeline to the waveform.

Example:

// es6
import TimelinePlugin from 'wavesurfer.timeline.js';

// commonjs
var TimelinePlugin = require('wavesurfer.timeline.js');

// if you are using <script> tags
var TimelinePlugin = window.WaveSurfer.timeline;

// ... initialising wavesurfer with the plugin
var wavesurfer = WaveSurfer.create({
  // wavesurfer options ...
  plugins: [
    TimelinePlugin.create({
      // plugin options ...
    })
  ]
});

Static Method Summary

Static Public Methods
public static

Timeline plugin definition factory

Constructor Summary

Public Constructor
public

Creates an instance of TimelinePlugin.

Method Summary

Public Methods
public

defaultFormatTimeCallback(seconds: number, pxPerSec: number): *

Turn the time into a suitable label for the time.

public

Return the cadence of notches that get labels in the primary color.

public

Return the cadence of notches that get labels in the secondary color.

public

defaultTimeInterval(pxPerSec: *): *

Return how many seconds should be between each notch

public

Destroy function used by the plugin API

public

init()

Initialisation function used by the plugin API

Inherited Summary

From class Observer
public

fireEvent(event: string, args: ...any)

Manually fire an event

public

Attach a handler function for an event.

public

once(event: string, handler: function): ListenerDescriptor

Attach a handler to an event.

public

un(event: string, fn: function)

Remove an event handler.

public

unAll()

Remove all event handlers.

Static Public Methods

public static create(params: TimelinePluginParams): PluginDefinition source

Timeline plugin definition factory

This function must be used to create a plugin definition which can be used by wavesurfer to correctly instantiate the plugin.

Params:

NameTypeAttributeDescription
params TimelinePluginParams

parameters use to initialise the plugin

Return:

PluginDefinition

an object representing the plugin

Public Constructors

public constructor(params: TimelinePluginParams, ws: object) source

Creates an instance of TimelinePlugin.

You probably want to use TimelinePlugin.create()

Override:

Observer#constructor

Params:

NameTypeAttributeDescription
params TimelinePluginParams

Plugin parameters

ws object

Wavesurfer instance

Public Methods

public defaultFormatTimeCallback(seconds: number, pxPerSec: number): * source

Turn the time into a suitable label for the time.

Params:

NameTypeAttributeDescription
seconds number
pxPerSec number

Return:

*

public defaultPrimaryLabelInterval(pxPerSec: *): number source

Return the cadence of notches that get labels in the primary color.

Params:

NameTypeAttributeDescription
pxPerSec *

Return:

number

public defaultSecondaryLabelInterval(pxPerSec: *): number source

Return the cadence of notches that get labels in the secondary color.

Params:

NameTypeAttributeDescription
pxPerSec *

Return:

number

public defaultTimeInterval(pxPerSec: *): * source

Return how many seconds should be between each notch

Params:

NameTypeAttributeDescription
pxPerSec *

Return:

*

public destroy() source

Destroy function used by the plugin API

public init() source

Initialisation function used by the plugin API