Interface: INotificationSound

INotificationSound

Audio object that is used for the sound notifications by the mmir.NotificationManager.

Extends

Members

protectedisNotificationPlayingBoolean

Flag for the play status.

nameString

The name / identifier for the sound.

protectedonErrorListenerfunction

The callback for "error" events.

protectedonFinishedListenerfunction

The callback for "finished" events.

protectedrepeatNotificationNumber

Field that holds the value for the repeat number: specifies how many times the sound should be played, before isNotificationPlaying is set to false.

MUST be >= 1, otherwise the sound will not be played.

Methods

inherited 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
url String the URL for the audio file
onPlayedCallback function optional OPTIONAL callback that is triggered when audio did play and has ended
failureCallBack function 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 be null)
onLoadedCallBack function 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)
See:
Example
var audio = mmir.MediaManager.getURLAsAudio(url, null, null, function onReady(){
 	audio.play();
 });

clearCallbacks()

Clears the "finished" and "error" callbacks.

inherited protecteddisable()

Disable audio (should only be used internally).
Enable audio (should only be used internally).

protectedfireError(error)

Fires the "error" event for its callback (if one is set).
Name Type Description
error any the error that occurred

protectedfireFinished()

Fires the "finished" event for its callback (if one is set).
Get the duration of the audio file
Returns:
Type Description
Number the duration in MS (or -1 if unknown)
Check if audio is currently enabled
Returns:
Type Description
Boolean true if enabled
Check if audio is currently paused.

NOTE: the state "paused" is a different status than state "stopped".

Returns:
Type Description
Boolean true if paused, false otherwise
Play audio.
Returns:
Type Description
Boolean true, if playing was started immediately. If false, the Audio object may have been disabled, or is still preparing (in which case it is auto-started, when preparing completes)

playNotification(repeatNTimes)

Field that holds the value for the repeat number: specifies how many times the sound should be played, before isNotificationPlaying is set to false.

MUST be >= 1, otherwise the sound will not be played.

Name Type Description
repeatNTimes Number specifies how many times the sound should be played, before isNotificationPlaying is set to false.
MUST be >= 1, otherwise the sound will not be played.
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.

setCallbacks(onFinished, onError)

Set callback functions for when the sound has finished playing, and for errors.

The sound finishes playing, when its audio object has been played repeatNTimes as specified when invoking function playNotification(repeatNTimes).

Name Type Description
onFinished function the callback for the finished event
onError function the callback for errors
Set the volume of this audio file
Name Type Description
value Number the new value for the volume: a number between [0.0, 1.0]
Stop playing audio.
Returns:
Type Description
Boolean true, if stopping was successful.