Home Reference Source Test
import MicrophonePlugin from 'wavesurfer.js/src/plugin/microphone/index.js'
public class | source

MicrophonePlugin

Extends:

Observer → MicrophonePlugin

Implements:

Visualize microphone input in a wavesurfer instance.

Example:

// es6
import MicrophonePlugin from 'wavesurfer.microphone.js';

// commonjs
var MicrophonePlugin = require('wavesurfer.microphone.js');

// if you are using <script> tags
var MicrophonePlugin = window.WaveSurfer.microphone;

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

Static Method Summary

Static Public Methods
public static

Microphone plugin definition factory

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

browser: *

public
public
public
public
public
public
public
public
public

params: *

public
public
public

stream: *

public

Method Summary

Public Methods
public

Connect the media sources that feed the visualization.

public

Destroy the microphone plugin.

public

Browser detector.

public

Device error callback.

public

Disconnect the media sources that feed the visualization.

public

extractVersion(uastring: string, expr: string, pos: number): number

Extract browser version out of the provided user agent string.

public

gotStream(stream: MediaStream)

Audio input device is ready.

public

init()

public

pause()

Pause visualization.

public

play()

Play visualization.

public

Redraw the waveform.

public

start()

Allow user to select audio input device, e.g.

public

stop()

Stop the device stream and remove any remaining waveform drawing from the wavesurfer canvas.

public

Stop the device and the visualization.

public

Pause/resume visualization.

Inherited Summary

From class Observer
public
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

Disable firing a list of events by name.

since 4.0.0
public

un(event: string, fn: function)

Remove an event handler.

public

unAll()

Remove all event handlers.

Static Public Methods

public static create(params: MicrophonePluginParams): PluginDefinition source

Microphone 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 MicrophonePluginParams

parameters use to initialise the plugin

Return:

PluginDefinition

an object representing the plugin

Public Constructors

public constructor() source

Instantiate Observer

Override:

Observer#constructor

Public Members

public active: boolean source

public browser: * source

public bufferSize: * source

public constraints: * source

public levelChecker: * source

public localAudioBuffer: * source

public mediaStreamSource: * source

public micContext: * source

public numberOfInputChannels: * source

public numberOfOutputChannels: * source

public params: * source

public paused: boolean source

public reloadBufferFunction: * source

public stream: * source

public wavesurfer: * source

Public Methods

public connect() source

Connect the media sources that feed the visualization.

public destroy() source

Destroy the microphone plugin.

public detectBrowser(): object source

Browser detector.

Return:

object

result containing browser, version and minVersion properties.

public deviceError(code: string) source

Device error callback.

Params:

NameTypeAttributeDescription
code string

Error message

public disconnect() source

Disconnect the media sources that feed the visualization.

public extractVersion(uastring: string, expr: string, pos: number): number source

Extract browser version out of the provided user agent string.

Params:

NameTypeAttributeDescription
uastring string
  • nullable: false

userAgent string.

expr string
  • nullable: false

Regular expression used as match criteria.

pos number
  • nullable: false

position in the version string to be returned.

Return:

number (nullable: false)

browser version.

public gotStream(stream: MediaStream) source

Audio input device is ready.

Params:

NameTypeAttributeDescription
stream MediaStream

The microphone's media stream.

public init() source

public pause() source

Pause visualization.

public play() source

Play visualization.

public reloadBuffer(event: object) source

Redraw the waveform.

Params:

NameTypeAttributeDescription
event object

Audioprocess event

public start() source

Allow user to select audio input device, e.g. microphone, and start the visualization.

public stop() source

Stop the device stream and remove any remaining waveform drawing from the wavesurfer canvas.

public stopDevice() source

Stop the device and the visualization.

public togglePlay() source

Pause/resume visualization.