Class: Html5AudioOutput

Html5AudioOutput

mmir.env.media.Html5AudioOutput

Audio handling for web / HTML5 environment

Requires

  • module:window.URL

Members

protected,readonly_pluginName

Default Value:
  • "webAudio"

constantMediaErrorArray.<String>

Media error (codes): the corresponding code is their index.

Code 0 is an internal error code for unknown/unspecific error causes.
Codes 1 - 4 correspond to the HTML5 MediaError interface (which are the same as Cordova's Audio MediaError codes). The description texts are taken from the HTML5 documentation.

See:

Methods

privatecreateDataUrl(blob, callback)

HELPER for creating data-URL from binary data (blob)
Name Type Description
blob Blob The audio data as blob
callback function callback that will be invoked with the data-URL: callback(dataUrl)

privatecreateError(code, errorEvent){Object}

HELPER for creating error object that is returned in the failureCallbacks
Name Type Description
code Number The error code: if in [1,4], the corresponding HTML5 MediaError information will be returned Otherwise an "error 0", i.e. internal/unknown error will be created
errorEvent Event | Error the causing event- or error-object
Returns:
Type Description
Object the error object, which has 3 properties: code (Number): the error code message (String): the error name description (String): a descriptive text for the error

privatecreateErrorWrapper(ctx, errorCallback){function}

FACTORY for creating error-listeners (that trigger the failureCallback)
Name Type Description
ctx Object optional the context for the errorCallback. IF omitted, the callback will be within the default (i.e. global) context.
errorCallback function optional the error callback. Is invoked with 2 arguments: errorCallback(error, event) where error has 3 properties: code (Number): the error code message (String): the error name description (String): a descriptive text for the error IF omitted, the error will be printed to the console.
Returns:
Type Description
function wrapper function that can be registered as event-listener (takes one argument: the event)
Get an audio object for the audio file specified by URL URL or by WAV data. NOTE that getWAVAsAudio may not be supported by all modules! Convenience function for getURLAsAudio and getWAVAsAudio: if first argument is a String, then getURLAsAudio will be invoked, otherwise getWAVAsAudio (if the module supports this function).
See:

getURLAsAudio(url, onPlayedCallback, failureCallback, onLoadedCallback){mmir.env.media.IAudio}

Get an audio object for the audio file specified by URL. The audio object exports the following functions:
play()
stop()
release()
enable()
disable()
setVolume(number)
getDuration()
isPaused()
isEnabled()
NOTE: the audio object should only be used, after the onLoadedCallback was triggered.
Name Type Description
url String
onPlayedCallback function optional OPTIONAL
failureCallback function optional OPTIONAL
onLoadedCallback function optional OPTIONAL
See:
Returns:
Type Description
mmir.env.media.IAudio the audio

getWAVAsAudio()

See:
  • mmir.MediaManager#getWAVAsAudio

privatehandlePlayPromise(p, audio, errorHandler){mmir.env.media.IAudio}

HELPER for handling new play() promise mechanism: play may get rejected due to no user-interaction -> trigger 'errorplay' event on MediaManager
Name Type Description
p Promise | void The promise returned by calling WebAudio.play() (or FALSY, if no promise was returned)
audio IAudio The audio object for which play was invoked
errorHandler function The error handler/callback for the audio
Returns:
Type Description
mmir.env.media.IAudio the audio
Play audio file from the specified URL or WAV data. Convenience function for playWAV and playURL: if first argument is a String, then playURL will be invoked, otherwise playWAV.
See:
Play audio file from the specified URL.
See:
Play PCM audio data.
See:

privatereleaseDataUrl(dataUrl)

HELPER for releasing data-URL
Name Type Description
dataUrl String The data URL for the audio blob