Microphone

Provides a consistent API to the microphone on all platforms.

The Microphone API provides access to the audio surrounding the mobile device.

For privacy reasons, a browser requires the user's consent before accessing the microphone. It is strongly recommended that best practices are followed to give the user an optimal experience and increase the engagement rate of your audience. (See here, for examples.)

Compatibility: Due to browser requirements, VideoStack is only able to access the microphone on iOS 11+, and Android 6+.

Example

var microphone = new VideoStack.Microphone();

microphone.start(function(e) {
  console.log(e.volume);
});

microphone.stop();

Constructor

new VideoStack.Microphone()

Create a new Microphone instance.

This constructor takes no parameters.

var microphone = new VideoStack.Microphone();

Instance Methods

start(callback, [context])

Start receiving microphone updates.

Argument Type Description
callback Function Callback function that receives an object as an argument

  • function(e)
  • e.volume {Number}
    The current volume in decibels between -100dB (silence) to 0dB (loudest system sound).
  • e.audioAnalyser {Object}
    The Web Audio API AnalyserNode provides real-time frequency and time-domain analysis.
  • e.audioSource {Object}
    The Wed Audio API MediaStreamAudioSourceNode representation of the audio source.
  • e.timeStamp {Number}
    The time in milliseconds when the data is collected.
context Object Context in which to invoke the callback (optional).
microphone.start(function(e) {
  console.log(e.volume);
});

stop()

Stop microphone updates.

microphone.stop();