index.js
function MediaRecorder (stream) {
  /**
   * The `MediaStream` passed into the constructor.
   * @type {MediaStream}
   */
  this.stream = stream

  /**
   * The current state of recording process.
   * @type {"inactive"|"recording"|"paused"}
   */
  this.state = 'inactive'

  this.em = document.createDocumentFragment()
  this.encoder = createWorker(MediaRecorder.encoder)

  var recorder = this
  this.encoder.addEventListener('message', function (e) {
    var event = new Event('dataavailable')
    event.data = new Blob([e.data], { type: recorder.mimeType })
    recorder.em.dispatchEvent(event)
    if (recorder.state === 'inactive') {
      recorder.em.dispatchEvent(new Event('stop'))
    }
  })
}
function MediaRecorder (stream) {
  /**
   * The `MediaStream` passed into the constructor.
   * @type {MediaStream}
   */
  this.stream = stream

  /**
   * The current state of recording process.
   * @type {"inactive"|"recording"|"paused"}
   */
  this.state = 'inactive'

  this.em = document.createDocumentFragment()
  this.encoder = createWorker(MediaRecorder.encoder)

  var recorder = this
  this.encoder.addEventListener('message', function (e) {
    var event = new Event('dataavailable')
    event.data = new Blob([e.data], { type: recorder.mimeType })
    recorder.em.dispatchEvent(event)
    if (recorder.state === 'inactive') {
      recorder.em.dispatchEvent(new Event('stop'))
    }
  })
}
function MediaRecorder ( stream ) { /**
   * The `MediaStream` passed into the constructor.
   * @type {MediaStream}
   */ this . stream = stream /**
   * The current state of recording process.
   * @type {"inactive"|"recording"|"paused"}
   */ this . state = 'inactive' this . em = document . createDocumentFragment ( ) this . encoder = createWorker ( MediaRecorder . encoder ) var recorder = this this . encoder . addEventListener ( 'message' , function ( e ) { var event = new Event ( 'dataavailable' ) event . data = new Blob ( [ e . data ] , { type : recorder . mimeType } ) recorder . em . dispatchEvent ( event ) if ( recorder . state === 'inactive' ) { recorder . em . dispatchEvent ( new Event ( 'stop' ) ) } } ) }
Audio Recorder with MediaRecorder API.

@param {MediaStream} stream The audio stream to record.

@example
navigator.mediaDevices.getUserMedia({ audio: true }).then(function (stream) {
var recorder = new MediaRecorder(stream)
})

@class
Audio Recorder with MediaRecorder API .