new CB_AudioFile_API.ACMP(filePath [, audioId] [, options] [, callbackOk] [, callbackError]) → {CB_AudioFile_API.ACMP}
The constructor is recommended to be called through a user-driven event (as onClick, onTouch, etc.) if the "autoPlay" option is set to true, as some web clients may need this at least the first time in order to be able to play the audio.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
filePath |
string | The path of the audio file or a data URI. NOTE: Only some clients with some audio APIs will support data URIs. |
||
audioId |
string |
<optional> |
'CB_AUDIOFILE_ACMP_' + CB_AudioFile_API.ACMP._idUnique++ | Desired identifier for the audio object. If not provided, an automatic unique ID will be calculated. Note that it is not case sensitive and it should be unique for each object. |
options |
CB_AudioFile_API.ACMP.OPTIONS |
<optional> |
CB_AudioFile_API.ACMP#DEFAULT_OPTIONS | Object with the desired options. |
callbackOk |
function |
<optional> |
Function with no parameters to be called when the audio has been loaded successfully, being "this" the |
|
callbackError |
function |
<optional> |
Function to be called if the audio has not been loaded successfully. The first and unique parameter will be a string describing the error found (if could be determined), being "this" the |
- Source:
- To Do:
-
- Do not allow to create one object with an "id" which has already been used (unless the value is undefined, null...). Note that the "id" is not case sensitive and it should be unique for each object.
- Method getCopy and static method filterProperties (similar to the ones from
CB_GraphicSprites
andCB_GraphicSpritesScene
).
Returns:
Returns a new CB_AudioFile_API.ACMP
object.
Members
-
<constant> DEFAULT_OPTIONS :CB_AudioFile_API.ACMP.OPTIONS
-
Keeps the default options when an object is created. Format: { autoLoad: boolean, autoPlay: boolean, loop: boolean, volume: number }.
Type:
- Default Value:
-
- { autoLoad: true, autoPlay: false, loop: false, volume:
CB_AudioFile_API.ACMP.prototype.DEFAULT_VOLUME
}
- { autoLoad: true, autoPlay: false, loop: false, volume:
- Source:
-
<constant> DEFAULT_VOLUME :number
-
Keeps the default volume. If the
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_DEFAULT
property is true, this will keep the result of calling theCB_Speaker.getVolume
function. Otherwise, it will use the value of theCB_Configuration.CrossBase.CB_Speaker_DEFAULT_VOLUME
variable.Type:
- number
- Default Value:
-
- CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_DEFAULT ? CB_Speaker.getVolume() : CB_Configuration.CrossBase.CB_Speaker_DEFAULT_VOLUME
- Source:
-
<readonly> filePath :string
-
Stores the path of the audio file or the data URI. NOTE: Only some clients with some audio APIs will support data URIs.
Type:
- string
-
<readonly> id :string
-
Stores the identifier for the audio file.
Type:
- string
- Default Value:
-
- 'CB_AUDIOFILE_ACMP_' + CB_AudioFile_API.ACMP._idUnique++
- Source:
-
<readonly> lastStartAt :number
-
Stores the last "startAt" parameter value used by the
CB_AudioFile_API.ACMP#play
or theCB_AudioFile_API.ACMP#resume
method.Type:
- number
-
<readonly> lastStopAt :number
-
Stores the last "stopAt" parameter value used by the
CB_AudioFile_API.ACMP#play
or theCB_AudioFile_API.ACMP#resume
method.Type:
- number
-
<readonly> loop :boolean
-
Defines whether the file loops by default when the audio is played or not. Its value will be modified automatically whenever the
CB_AudioFile_API.ACMP#play
method is called, getting the value from the "loop" parameter (but only if contains a boolean).Type:
- boolean
- Default Value:
- Source:
-
<readonly> mediaObject :Object
-
Stores the Media object of the audio, used by the "ACMP" (Apache Cordova Media Plugin).
Type:
- Object
-
<readonly> onStopFunction :function
-
Function to call when the audio stops.
Type:
- function
-
<readonly> pauseTime :number
-
Stores the time (in milliseconds) when the audio has been paused.
Type:
- number
-
<readonly> paused :boolean
-
Tells whether the audio is paused or not.
Type:
- boolean
- Default Value:
-
- false
- Source:
-
<readonly> position :number
-
Stores the current position (in seconds) where the audio is playing (returned by the getCurrentPosition method), used by the "ACMP" (Apache Cordova Media Plugin).
Type:
- number
-
<readonly> status :integer
-
Tells whether the file is unloaded (
CB_AudioFile.UNLOADED
), loading (CB_AudioFile.LOADING
), unchecked (CB_AudioFile.UNCHECKED
), checking (CB_AudioFile.CHECKING
), loaded (CB_AudioFile.LOADED
), failed (CB_AudioFile.FAILED
) or aborted (CB_AudioFile.ABORTED
).Type:
- integer
- Default Value:
- Source:
-
<readonly> stopped :boolean
-
Tells whether the audio is stopped or not.
Type:
- boolean
- Default Value:
-
- true
- Source:
-
<readonly> volume :number
-
Stores the volume of this audio. Accepted values go from 0 to MAX_VOLUME, where MAX_VOLUME is 100 if the
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is false or otherwise MAX_VOLUME is the returning value of theCB_Speaker.getVolume
function.Type:
- number
- Default Value:
- Source:
-
<readonly> volumeBeforeMute :number
-
Stores the volume of this audio before it was muted (to restore it later). Valid values go from 0 to MAX_VOLUME, where MAX_VOLUME is 100 if the
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is false or otherwise MAX_VOLUME is the returning value of theCB_Speaker.getVolume
function.Type:
- number
- Default Value:
- Source:
Methods
-
checkPlaying( [callbackOk] [, callbackError] [, ignoreStatus] [, ignoreQueue] [, useCache] [, isSwapObject]) → {boolean}
-
Checks whether the audio can be played or not. Recommended to be called through a user-driven event (as onClick, onTouch, etc.), as some web clients may need this at least the first time in order to be able to play the audio. Also recommended to use before calling the
CB_AudioFile_API.ACMP#play
method the first time. The checking action will only be performed if the value of theCB_AudioFile_API.ACMP#status
property belongs to theCB_AudioFile.UNCHECKED
or to theCB_AudioFile.CHECKING
value. After checking, if the audio can be played, theCB_AudioFile_API.ACMP#status
of the object will get the value ofCB_AudioFile.LOADED
. Otherwise, if it cannot be played, theCB_AudioFile_API.ACMP#status
property will get the value of {CB_AudioFile.FAILED}.Parameters:
Name Type Argument Default Description callbackOk
function <optional>
Function with no parameters to be called when the audio has been checked successfully, being "this" the
CB_AudioFile_API.ACMP
object itself.callbackError
function <optional>
Function to be called if the audio has not been checked successfully. The first and unique parameter will be a string describing the error found (if it could be determined), being "this" the
CB_AudioFile_API.ACMP
object itself.ignoreStatus
boolean <optional>
false If set to false and the
CB_AudioFile_API.ACMP#status
property does not belong neither to the "UNCHECKED" status (defined in theCB_AudioFile.UNCHECKED
constant) nor to the "CHECKING" status (defined in theCB_AudioFile.CHECKING
constant), it will fail calling the "callbackError" function (if any). If set to true, it will try to perform the checking action regardless the status of the audio.ignoreQueue
boolean <optional>
false This parameter will be ignored in this audio API.
useCache
boolean <optional>
false This parameter will be ignored in this audio API.
isSwapObject
boolean <optional>
false Defines whether the Media object to check is a swap object or the normal one (a swap object is stored internally as it is necessary due ACMP issues when looping a sprite near the end of the audio file). Internal usage only recommended.
Returns:
Returns false if the checking could not be performed and failed. If it returns true, it can mean either the checking has been processed successfully or it will fail in the future, so it is recommended to ignore the returning value and use the callback functions instead.
- Type
- boolean
-
destructor( [stopSound] [, keepStoppedUnaltered] [, avoidOnStop] [, forceOnStop])
-
Destroys the audio file object and frees memory. Sets its current
CB_AudioFile_API.ACMP#status
property to ABORTED (CB_AudioFile.ABORTED
value).Parameters:
Name Type Argument Default Description stopSound
boolean <optional>
false If set to true, it will also call the
CB_AudioFile_API.ACMP#stop
method.keepStoppedUnaltered
boolean <optional>
false Used internally as the "keepStoppedUnaltered" parameter to call the
CB_AudioFile_API.ACMP#stop
method. If the "stopSound" parameter is not set to true, this parameter will be ignored as the "stop" method will not be called.avoidOnStop
boolean <optional>
false Used internally as the "avoidOnStop" parameter to call the
CB_AudioFile_API.ACMP#stop
method. If the "stopSound" parameter is not set to true, this parameter will be ignored as the "stop" method will not be called.forceOnStop
boolean <optional>
false Used internally as the "forceOnStop" parameter to call the
CB_AudioFile_API.ACMP#stop
method. If the "stopSound" parameter is not set to true, this parameter will be ignored as the "stop" method will not be called. -
getCurrentTime() → {number}
-
Gets the current time (in milliseconds) which belongs to the position where the audio is currently playing or where it has been paused. Note that some audio APIs and clients could give wrong values.
Returns:
Returns the current time (in milliseconds). Note that some audio APIs and clients could give wrong values.
- Type
- number
-
getDuration( [mediaObject]) → {number}
-
Tells the duration of the audio (in milliseconds). Note that some clients might not calculate the duration correctly and, in this case, a zero (0) value would be returned.
Parameters:
Name Type Argument Default Description mediaObject
Object <optional>
CB_AudioFile_API.ACMP#mediaObject
Media object whose audio duration we want to check. Used internally to check either normal or swap Media object (a swap object is stored internally as it is necessary due ACMP issues when looping a sprite near the end of the audio file). Internal usage only recommended.
Returns:
Returns the duration of the audio (in milliseconds). Note that some clients might not calculate the duration correctly and, in this case, a zero (0) value would be returned.
- Type
- number
-
getProgress() → {number}
-
Returns a number representing the percentage of the loading progress for the audio file (from 0 to 100, being 100 a complete loading progress). The way to calculate it internally may differ from one audio API to another and it is not totally reliable.
Returns:
Returns a number representing the percentage of the loading progress for the audio file (from 0 to 100, being 100 a complete loading progress). The way to calculate it internally may differ from one audio API to another and it is not totally reliable.
- Type
- number
-
load( [filePath] [, autoPlay] [, callbackOk] [, callbackError] [, forceReload]) → {CB_AudioFile_API.ACMP|null}
-
Loads the desired audio file with the desired options. Recommended to be called through a user-driven event (as onClick, onTouch, etc.), as some web clients may need this at least the first time in order to be able to play the audio. This method will be called automatically by the constructor if the "autoLoad" option was set to true in its given "options" parameter.
When this method is called, if theCB_AudioFile_API.ACMP#status
property already has the "LOADED" status (defined in theCB_AudioFile.LOADED
constant) and the "forceReload" parameter is not set to true, it will exit calling the given "callbackOk" function (if any) immediately. Otherwise, regardless the status, the status will be set to "LOADING" (defined in theCB_AudioFile.LOADING
constant). After it, it will reach the "UNCHECKED" (defined in theCB_AudioFile.UNCHECKED
constant). If the "autoPlay" parameter is not set to true, this will be the final status (and it will be necessary to call theCB_AudioFile_API.ACMP#checkPlaying
method after it). After it and only if the "autoPlay" is set to true, as theCB_AudioFile_API.ACMP#checkPlaying
method will be called internally, it will have the "CHECKING" status (defined in theCB_AudioFile.CHECKING
constant) and finally the "LOADED" status (defined in theCB_AudioFile.LOADED
constant) if all goes well.Parameters:
Name Type Argument Default Description filePath
string <optional>
CB_AudioFile_API.ACMP#filePath
The path of the audio file or a data URI. NOTE: Only some clients with some audio APIs will support data URIs.
autoPlay
string <optional>
false If set to true, it will start playing the audio automatically (by calling the
CB_AudioFile_API.ACMP#play
method internally). If set to true and theCB_AudioFile_API.ACMP#status
property reaches to the "UNCHECKED" status (defined in theCB_AudioFile.UNCHECKED
constant), it will also call internally theCB_AudioFile_API.ACMP#checkPlaying
method.callbackOk
function <optional>
Function with no parameters to be called when the audio has been loaded successfully, being "this" the
CB_AudioFile_API.ACMP
object itself.callbackError
function <optional>
Function to be called if the audio has not been loaded successfully. The first and unique parameter will be a string describing the error found (if it could be determined), being "this" the
CB_AudioFile_API.ACMP
object itself.forceReload
boolean <optional>
false If set to false, the "filePath" has not been changed from the previously used and the
CB_AudioFile_API.ACMP#status
property belongs to the "LOADED" status (defined in theCB_AudioFile.LOADED
constant), it will exit the method without loading the audio file again (calling the "callbackOk" function, if any).Returns:
Returns the audio API object (if it was possible to create) or null otherwise.
- Type
- CB_AudioFile_API.ACMP | null
-
mute( [onMute]) → {number}
-
Mutes the audio file.
Parameters:
Name Type Argument Description onMute
function <optional>
Callback function which will be called if it has been possible to mute the audio file (or at least it was possible to try it). It will not receive any parameters, being "this" the
CB_AudioFile_API.ACMP
object.Returns:
Returns the current volume (from 0 to the maximum value, where the maximum value will be the returning value of calling the
CB_Speaker.getVolume
function if theCB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is set to true or it will be 100 otherwise). If all goes well, the returning value should be zero (0). Note that, even when it returns a zero (0) value, this does not always mean that the mute has been applied successfully.- Type
- number
-
onStop(callbackFunction [, keepOldFunction]) → {boolean}
-
Sets a function to execute when the audio file stops playing or removes it.
Parameters:
Name Type Argument Default Description callbackFunction
function | null The function (event listener) that we want to execute when the event is fired. No parameters will be received, being "this" the
CB_AudioFile_API.ACMP
object. If a null value is used, the event will be removed.keepOldFunction
boolean <optional>
true Defines whether we want to keep any possible previous event listener or not.
Returns:
Returns whether the event has been set or not (removed).
- Type
- boolean
-
pause( [onPause] [, keepPausedUnaltered]) → {boolean}
-
Pauses the audio when it is being played.
Parameters:
Name Type Argument Default Description onPause
function <optional>
Function without parameters to be called when the audio is paused successfully, being "this" the
CB_AudioFile_API.ACMP
object.keepPausedUnaltered
boolean <optional>
false If set to true (not recommended), the
CB_AudioFile_API.ACMP#paused
property will not be set to true and it will remain with its current value.Returns:
It returns false if the audio is already paused or it is stopped or if it cannot be paused. Returns true otherwise.
- Type
- boolean
-
play( [startAt] [, stopAt] [, loop] [, avoidDelayedPlay] [, allowedRecursiveDelay] [, onPlayStart] [, onLoadError] [, isResume] [, isLooping] [, startPlayingTime]) → {boolean|integer}
-
Plays the audio.
Parameters:
Name Type Argument Default Description startAt
number <optional>
0 | CB_AudioFile_API.ACMP#lastStartAt
| stopAtTime in milliseconds where we want the audio to start at. If not provided or it is not a valid number, it will use zero (0) as default which belongs to the beginning of the audio. If the value provided is greater than the "stopAt" provided, it will use the value set in the
CB_AudioFile_API.ACMP#lastStartAt
property (which belongs to the "startAt" value the last time that this method was called). If, even using theCB_AudioFile_API.ACMP#lastStartAt
value is still greather than the "stopAt" provided, it will use the same value as the "stopAt" which means it will not play and will stop immediately.stopAt
number <optional>
CB_AudioFile_API.ACMP#getDuration
()Time in milliseconds where we want the audio to stop at. If not provided or it is not a valid number, it will use the returning value of the
CB_AudioFile_API.ACMP#getDuration
method (which should belong to the total duration of the audio, if it was calculated correctly).loop
boolean <optional>
CB_AudioFile_API.ACMP#loop
Sets whether we want to play the audio looping (starting again and again) or just play it once. Note that at the end of each loop the "onStop" function defined (through the
CB_AudioFile_API.ACMP#onStop
method) will not be called.avoidDelayedPlay
boolean <optional>
false If set to false (recommended) and the audio failed previously or was aborted (destroyed), it will try to load it correctly again automatically and play it after that if possible (this can take some time so the audio could start playing after a delay). Otherwise, if set to true and the audio failed or was aborted (destroyed), the audio will not play at all and the "stop" method will be called immediately.
allowedRecursiveDelay
boolean <optional>
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_ALLOWED_RECURSIVE_DELAY_DEFAULT
The maximum amount of time (in milliseconds) of delay that we accept before start playing the audio. If the amount of time is overcome, the audio will not play at all and the
CB_AudioFile_API.ACMP#stop
method will be called immediately. Used only when the "avoidDelayedPlay" parameter is set to false and the audio needs to be loaded because it failed previously or was aborted (destroyed).onPlayStart
function <optional>
Function to be called when the audio starts playing successfully. The function will be called with the following parameters (in order): "startAt", "stopAt", "startAtNextLoop", "loop", "avoidDelayedPlay", "allowedRecursiveDelay" and "startPlayingTime", being "this" the
CB_AudioFile_API.ACMP
object. If the audio is looping, this will be called only once when the audio starts playing the first time and it will not be called next loops.onLoadError
function <optional>
Function to be called if the audio cannot be played successfully. The first and unique parameter will be a string describing the error found (if it could be determined), being "this" the
CB_AudioFile_API.ACMP
object.isResume
boolean <optional>
false If set to true (not recommended) and it is a looping audio, the next loop will use the value of the
CB_AudioFile_API.ACMP#lastStartAt
property as the "startAt" parameter when it calls this method again automatically (internally). Recommended for internal usage only.isLooping
boolean <optional>
false Used to determine whether this method was called automatically again by itself because it is looping the audio. Recommended for internal usage only.
startPlayingTime
integer <optional>
Contains the time when the audio should start playing. Recommended for internal usage only.
Returns:
It returns false if the duration is 0 ("startAt" and "stopAt" are the same number), returns "-1" if the audio cannot be played and an error is detected or returns true otherwise. Note that even when it returns true there can be a non-detectable error and maybe the audio is not played.
- Type
- boolean | integer
-
resume( [loop] [, avoidDelayedPlay] [, allowedRecursiveDelay] [, onPlayStart] [, onLoadError]) → {boolean|integer}
-
Resumes the audio (after being paused), starting from the same point it was paused previously.
Parameters:
Name Type Argument Default Description loop
boolean <optional>
CB_AudioFile_API.ACMP#loop
Sets whether we want to play the audio looping (starting again and again) or just play it once. Note that at the end of each loop the "onStop" function defined (through the
CB_AudioFile_API.ACMP#onStop
method) will not be called.avoidDelayedPlay
boolean <optional>
false If set to false (recommended) and the audio failed previously or was aborted (destroyed), it will try to load it correctly again automatically and play it after that if possible (this can take some time so the audio could start playing after a delay). Otherwise, if set to true and the audio failed or was aborted (destroyed), the audio will not play at all and the
CB_AudioFile_API.ACMP#stop
method will be called immediately.allowedRecursiveDelay
boolean <optional>
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_ALLOWED_RECURSIVE_DELAY_DEFAULT
The maximum amount of time (in milliseconds) of delay that we accept before start playing the audio. If the amount of time is overcome, the audio will not play at all and the
CB_AudioFile_API.ACMP#stop
method will be called immediately. Used only when the "avoidDelayedPlay" parameter is set to false and the audio needs to be loaded because it failed previously or was aborted (destroyed).onPlayStart
function <optional>
Function to be called when the audio starts playing successfully. The function will be called with the following parameters (in order): "startAt", "stopAt", "startAtNextLoop", "loop", "avoidDelayedPlay", "allowedRecursiveDelay" and "startPlayingTime", being "this" the
CB_AudioFile_API.ACMP
object. If the audio is looping, this will be called only once when the audio starts playing the first time and it will not be called next loops.onLoadError
function <optional>
Function to be called if the audio cannot be played successfully. It will not be called if the audio is not paused or is stopped. The first and unique parameter will be a string describing the error found (if it could be determined), being "this" the
CB_AudioFile_API.ACMP
object.Returns:
Returns the returning value of the
CB_AudioFile_API.ACMP#play
method which is called internally. It returns false if the audio is not paused or it is stopped, returns "-1" if the audio cannot be played and an error is detected or returns true otherwise. Note that even when it returns true there can be a non-detectable error and maybe the audio is not played.- Type
- boolean | integer
-
setVolume( [volume] [, forceSetVolumeProperty] [, onSetVolume] [, saveForUnmute] [, mediaObject]) → {number}
-
Sets the desired volume for the audio file (from 0 to the maximum value, where the maximum value will be the returning value of calling the
CB_Speaker.getVolume
function if theCB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is set to true or it will be 100 otherwise).Parameters:
Name Type Argument Default Description volume
number <optional>
CB_Speaker.getVolume()
|CB_Configuration.CrossBase.CB_Speaker_DEFAULT_VOLUME
Desired volume (from 0 to the maximum value, where the maximum value will be the returning value of calling the
CB_Speaker.getVolume
function if theCB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is set to true or it will be 100 otherwise).forceSetVolumeProperty
boolean <optional>
false If set to true (not recommended), it will change the
CB_AudioFile_API.ACMP#volume
property even when the volume failed to be changed.onSetVolume
function <optional>
Callback function which will be called if it has been possible to set the volume (or at least it was possible to try it). It will not receive any parameters, being "this" the
CB_AudioFile_API.ACMP
object.saveForUnmute
boolean <optional>
false If set to true (not recommended), it will save internally the current volume before setting it so it will restore the same volume again after calling the
CB_AudioFile_API.ACMP#unmute
method. Internal usage only recommended.mediaObject
Object <optional>
CB_AudioFile_API.ACMP#mediaObject
Media object whose volume we want to set. Used internally to affect either normal or swap Media object (a swap object is stored internally as it is necessary due ACMP issues when looping a sprite near the end of the audio file). Internal usage only recommended.
Returns:
Returns the current volume (from 0 to the maximum value, where the maximum value will be the returning value of calling the
CB_Speaker.getVolume
function if theCB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is set to true or it will be 100 otherwise).- Type
- number
-
stop( [keepStoppedUnaltered] [, avoidOnStop] [, forceOnStop]) → {boolean}
-
Stops the audio.
Parameters:
Name Type Argument Default Description keepStoppedUnaltered
boolean <optional>
false If set to true (not recommended), the
CB_AudioFile_API.ACMP#stopped
property will not be set to true and it will remain with its current value.avoidOnStop
boolean <optional>
false If set to false and there is an "onStop" function defined (through the
CB_AudioFile_API.ACMP#onStop
method), it will be called after stopping the audio (or after trying to do it, at least) but only if either the "forceOnStop" parameter is set to true or if the "keepStoppedUnaltered" parameter is set to false and the audio was not already stopped before. If set to true, the "onStop" function (if any) will not be called at all.forceOnStop
boolean <optional>
false If it is set to true and the "avoidOnStop" parameter is set to false and there is an "onStop" function defined (through the
CB_AudioFile_API.ACMP#onStop
method), it will be called regardless the audio was stopped before or not. If set to false, the "onStop" function (if any) will only be called if the "keepStoppedUnaltered" parameter is set to false and the audio was not already stopped before. This parameter will be ignored if the "avoidOnStop" parameter is set to true.Returns:
It returns false if the stopping action cannot be performed at all (this could happen when the audio has not been loaded properly, for example). Returns true otherwise (this only means that it has been tried to be stopped but it could not be successfully).
- Type
- boolean
-
unmute( [onUnmute]) → {number}
-
Restores audio after muting it (unmutes it).
Parameters:
Name Type Argument Description onUnmute
function <optional>
Callback function which will be called if it has been possible to unmute the audio file (or at least it was possible to try it). It will not receive any parameters, being "this" the
CB_AudioFile_API.ACMP
object.Returns:
Returns the current volume (from 0 to the maximum value, where the maximum value will be the returning value of calling the
CB_Speaker.getVolume
function if theCB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is set to true or it will be 100 otherwise).- Type
- number
Type Definitions
-
OPTIONS
-
Object with the options for an audio file. The format is the following one: { autoLoad: boolean, autoPlay: boolean, loop: boolean, volume: number }.
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description autoLoad
boolean <optional>
CB_AudioFile_API.ACMP#DEFAULT_OPTIONS
.autoLoadIf set to false, it will not call the
CB_AudioFile_API.ACMP#load
method internally when the constructor is called (not recommended).autoPlay
boolean <optional>
CB_AudioFile_API.ACMP#DEFAULT_OPTIONS
.autoPlayValue which will be used as the "autoPlay" parameter when calling the
CB_AudioFile_API.ACMP#load
method internally, only when the "autoLoad" is set to true (when the constructor is called).loop
boolean <optional>
CB_AudioFile_API.ACMP#DEFAULT_OPTIONS
.loopValue that will be used for the
CB_AudioFile_API.ACMP#loop
property.volume
number <optional>
CB_AudioFile_API.ACMP#DEFAULT_OPTIONS
.volumeThe desired volume (from 0 to the maximum value, where the maximum value will be the returning value of calling the
CB_Speaker.getVolume
function if theCB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_MAXIMUM
property is set to true or it will be 100 otherwise) that will be used for theCB_AudioFile_API.ACMP#volume
property.