The Audio abstraction that is returned by
mmir.MediaManager#getURLAsAudio.
NOTE: when an audio object is not used anymore, its release method should
be called.
Methods
-
protected_constructor(url, onPlayedCallback, failureCallBack, onLoadedCallBack)
-
The constructor.
NOTE that audio objects are created with a factory, e.g. via
mmir.MediaManager#getURLAsAudio.Name Type Description urlString the URL for the audio file onPlayedCallbackfunction optional OPTIONAL callback that is triggered when audio did play and has ended failureCallBackfunction optional OPTIONAL callback that is triggered when an error occurs (usually during initialization)
NOTE: this argument is positional (i.e. onPlayedCallback must be specified, but may benull)onLoadedCallBackfunction optional OPTIONAL callback that is triggered when audio has been initialized and is ready to be played NOTE: this argument is positional (i.e. onPlayedCallback and failureCallBack must be specified, but may be null)Example
var audio = mmir.MediaManager.getURLAsAudio(url, null, null, function onReady(){ audio.play(); }); -
protecteddisable()
-
Disable audio (should only be used internally).
-
protectedenable()
-
Enable audio (should only be used internally).
-
getDuration(){Number}
-
Get the duration of the audio file
Returns:
Type Description Number the duration in MS (or -1if unknown) -
isEnabled(){Boolean}
-
Check if audio is currently enabled
Returns:
Type Description Boolean trueif enabled -
isPaused(){Boolean}
-
Check if audio is currently paused.
NOTE: the state "paused" is a different status than state "stopped".
Returns:
Type Description Boolean trueif paused,falseotherwise -
play(){Boolean}
-
Play audio.
Returns:
Type Description Boolean true, if playing was started immediately. Iffalse, the Audio object may have been disabled, or is still preparing (in which case it is auto-started, when preparing completes) -
release()
-
Release audio: should be called when the audio file is not used any more.
NOTE some environments - such as Android - have limited resources available. Not releasing resources may result in not being able to instantiate new (audio) resources.
-
setVolume(value)
-
Set the volume of this audio file
Name Type Description valueNumber the new value for the volume: a number between [0.0, 1.0] -
stop(){Boolean}
-
Stop playing audio.
Returns:
Type Description Boolean true, if stopping was successful.