new CB_AudioFile(filePath [, audioId] [, options] [, audioAPI] [, callbackOk] [, callbackError]) → {CB_AudioFile}
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 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_' + CB_AudioFile._idUnique++ | Desired identifier for the audio object (can be a different element depending on the audio API used). 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.OPTIONS |
<optional> |
CB_AudioFile#DEFAULT_OPTIONS
|
Object with the desired options. |
audioAPI |
string |
<optional> |
CB_AudioDetector.getPreferredAPI(undefined, false, null) || CB_AudioDetector.getPreferredAPI(undefined, true, null) | The desired audio API to be used. If not provided, it will try to calculate the best one for the current client by calling the |
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 it 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.
- Send the
CB_AudioFile
object itself as a parameter when calling both "callbackOk" and "callbackError". - Think about allowing to define 'useXHR' and 'useCache' options (used by
CB_AudioFile_API.WAAPI
objects). - Method getCopy and static method filterProperties (similar to the ones from
CB_GraphicSprites
andCB_GraphicSpritesScene
).
Returns:
Returns a new CB_AudioFile
object.
- Type
- CB_AudioFile
Members
-
<constant> DEFAULT_OPTIONS :CB_AudioFile.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.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> audioAPI :string
-
Defines the Audio API used for this audio file. Audio API support will depend on the current client being used. All possible ones are defined in
CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS
. For example: "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API).Type:
- string
-
audioFileObject :CB_AudioFile_API.WAAPI|CB_AudioFile_API.SM2|CB_AudioFile_API.ACMP|CB_AudioFile_API.AAPI|Object
-
It will store the current audio file object for the current audio API. The
CB_AudioFile#load
method will set the value of this property only after the audio file object (stored in its value) is loaded properly. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API). When no audio API object is being set, it will contain a fake object with same methods and properties (defined inCB_AudioFile._audioFileObject_prototype
). Recommended for internal usage only.Type:
-
audioFileObjectLast :CB_AudioFile_API.WAAPI|CB_AudioFile_API.SM2|CB_AudioFile_API.ACMP|CB_AudioFile_API.AAPI|Object
-
Stores the last audio file object created or reused, for the current API being used. The
CB_AudioFile#load
method will set the value of this property before knowing whether the audio file object (stored in its value) will be loaded properly or not. Used by theCB_AudioFile#load
andCB_AudioFile#getProgress
methods. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API). When no audio API object is being set, it will contain a fake object with same methods and properties (defined inCB_AudioFile._audioFileObject_prototype
). Recommended for internal usage only.Type:
-
audioFileObjects :Object
-
It will store the created audio file objects for the different audio APIs (for optimization purposes, to avoid creating more than one per API). Being each index the name of the audio API ("WAAPI", "AAPI", "SM2" or "ACMP"), their value will be an object which can be
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API). Recommended for internal usage only.Type:
- Object
- Default Value:
-
- {}
- 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_' + CB_AudioFile._idUnique++
- Source:
-
<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#play
method is called, getting the value from the "loop" parameter (but only if contains a boolean).Type:
- boolean
- Default Value:
- 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:
-
<static, constant> ABORTED :integer
-
Status value for an audio file which has been aborted. This will happen when the audio file has been destroyed with the
CB_AudioFile#destructor
method. Can be used to compare the value returned by theCB_AudioFile#getStatus
method. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 6
- Source:
-
<static, constant> CHECKING :integer
-
Status value for an audio file which is being checked currently. Can be used to compare the value returned by the
CB_AudioFile#getStatus
method. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 3
- Source:
-
<static, constant> FAILED :integer
-
Status value for an audio file which failed to be loaded or failed for any other reason. Can be used to compare the value returned by the
CB_AudioFile#getStatus
method. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 5
- Source:
-
<static, constant> LOADED :integer
-
Status value for an audio file which has been loaded. Can be used to compare the value returned by the
CB_AudioFile#getStatus
method. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 4
- Source:
-
<static, constant> LOADING :integer
-
Status value for an audio file which is loading. Can be used to compare the value returned by the
CB_AudioFile#getStatus
method. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 1
- Source:
-
<static, constant> UNCHECKED :integer
-
Status value for an audio file which has been not checked yet. Can be used to compare the value returned by the
CB_AudioFile#getStatus
method. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 2
- Source:
-
<static, constant> UNLOADED :integer
-
Status value for an audio file which is unloaded. Can be used to compare the value returned by the
CB_AudioFile#getStatus
method. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 0
- Source:
Methods
-
checkPlaying( [callbackOk] [, callbackError] [, ignoreStatus] [, ignoreQueue] [, useCache]) → {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 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#play
method the first time. Internally, uses the "checkPlaying" method of the used audio API object. The checking action will only be performed if the value of the "status" property of the used audio API object belongs to theCB_AudioFile.UNCHECKED
or to theCB_AudioFile.CHECKING
value. After checking, if the audio can be played, the "status" property of the used audio API object will get the value ofCB_AudioFile.LOADED
. Otherwise, if it cannot be played, the "status" property of the used audio API object will get the value of {CB_AudioFile.FAILED}. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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
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
object itself.ignoreStatus
boolean <optional>
false If set to false and the audio status is neither "UNCHECKED" nor "CHECKING", 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 If set to false and there is already the maximum number of audio files being checked (defined internally, depending on the audio API), the function will exit and it will call itself automatically again and again until the checking process can be performed (when its queue turn has been reached). This is done for performance purposes. Some audio APIs will ignore this parameter as they do not use checking queues.
useCache
boolean <optional>
false If set to true (not recommended) and the same audio file was checked previously, it will not perform the checking process again and it will do the same as the previous call. Some audio APIs will ignore this parameter as they do not use cache.
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 status 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 "stop" method of the internal audio file object for the current API (stored in the
CB_AudioFile#audioFileObject
property). This method has the same parameters as theCB_AudioFile#stop
method.keepStoppedUnaltered
boolean <optional>
false Used internally as the "keepStoppedUnaltered" parameter to call the "stop" method of the internal audio file object for the current API (stored in the
CB_AudioFile#audioFileObject
property). This method has the same parameters as theCB_AudioFile#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 "stop" method of the internal audio file object for the current API (stored in the
CB_AudioFile#audioFileObject
property). This method has the same parameters as theCB_AudioFile#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 "stop" method of the internal audio file object for the current API (stored in the
CB_AudioFile#audioFileObject
property). This method has the same parameters as theCB_AudioFile#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. Internally, uses the "getCurrentTime" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Returns:
Returns the current time (in milliseconds). Note that some audio APIs and clients could give wrong values.
- Type
- number
-
getDuration() → {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. Internally, uses the "getDuration" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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. Internally, uses the "getProgress" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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
-
getStartAt( [numeric]) → {number|*}
-
Tells the last "startAt" parameter value used by the
CB_AudioFile#play
or theCB_AudioFile#resume
method (or used by the equivalents methods of the same name from the used audio API object). Internally, uses the "lastStartAt" property of the used audio API object. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Parameters:
Name Type Argument Default Description numeric
boolean <optional>
false If set to true, it will sanitize the returning value by returning zero instead of undefined, null or any other non-numeric value.
Returns:
Returns the last "startAt" value used by the
CB_AudioFile#play
or theCB_AudioFile#resume
method (or used by the equivalents methods of the same name from the used audio API object). If we want it to be numeric always, the "numeric" parameter should be set to true.- Type
- number | *
-
getStatus( [realStatus]) → {number}
-
Gets the current status of the audio file.
Parameters:
Name Type Argument Default Description realStatus
boolean <optional>
false If set to true, it will return the "status" property of the used audio API object instead of the "status" property of the current CB_AudioFile object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Returns:
Returns the current status of the audio file. It is a number, which should match the value of the CB_AudioFile.UNLOADED (still unloaded), CB_AudioFile.LOADING (loading), CB_AudioFile.UNCHECKED (not checked by calling the "checkPlaying" method yet), CB_AudioFile.CHECKING (being checked by the "checkPlaying" method), CB_AudioFile.LOADED (loaded), CB_AudioFile.FAILED (failed loading or failed to play or by any other reason) or CB_AudioFile.ABORTED (aborted because it was destroyed with the "destructor" method) property.
- Type
- number
-
getStatusString( [realStatus]) → {string}
-
Gets the current status of the audio file, as a string.
Parameters:
Name Type Argument Default Description realStatus
boolean <optional>
false If set to true, it will have in mind the "status" property of the used audio API object instead of the "status" property of the current CB_AudioFile object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Returns:
Returns the current status of the audio file, as a string. Possible return values are "UNLOADED", "LOADING", "UNCHECKED", "CHECKING", "LOADED", "FAILED", "ABORTED" or "UNKNOWN (UNKNOWN_STATUS)" (where "UNKNOWN_STATUS" will be a value from the "status" property not recognized as any possible status).
- Type
- string
-
getStopAt( [numeric]) → {number|*}
-
Tells the last "stopAt" parameter value used by the
CB_AudioFile#play
or theCB_AudioFile#resume
method (or used by the equivalents methods of the same name from the used audio API object). Internally, uses the "lastStopAt" property of the used audio API object. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Parameters:
Name Type Argument Default Description numeric
boolean <optional>
false If set to true, it will sanitize the returning value by returning zero instead of undefined, null or any other non-numeric value.
Returns:
Returns the last "stopAt" value used by the
CB_AudioFile#play
or theCB_AudioFile#resume
method (or used by the equivalents methods of the same name from the used audio API object). If we want it to be numeric always, the "numeric" parameter should be set to true.- Type
- number | *
-
getVolume() → {number}
-
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). Internally, uses the "volume" property of the used audio API object. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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
-
getVolumeBeforeMute() → {number}
-
Returns the 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 was set before the audio was muted. Internally, uses the "volumeBeforeMute" property of the used audio API object. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Returns:
Returns the 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 was set before the audio was muted. If the audio was not muted before, it will contain the default volume used in the "volume" property of the used audio API object.- Type
- number
-
isPaused() → {boolean}
-
Tells whether the audio is paused or not. Internally, uses the "paused" property of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Returns:
Returns whether the audio is paused or not.
- Type
- boolean
-
isPlaying() → {boolean}
-
Tells whether the audio file is playing or not. Internally, uses the
CB_AudioFile#isStopped
andCB_AudioFile#isPaused
methods.Returns:
Returns whether the audio file is playing or not.
- Type
- boolean
-
isStopped() → {boolean}
-
Tells whether the audio file is stopped or not. Internally, uses the "stopped" property of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Returns:
Returns whether the audio file is stopped or not.
- Type
- boolean
-
load( [filePath] [, audioAPI] [, autoPlay] [, callbackOk] [, callbackError] [, ignoreOldValues] [, forceReload]) → {CB_AudioFile_API.WAAPI|CB_AudioFile_API.SM2|CB_AudioFile_API.ACMP|CB_AudioFile_API.AAPI|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 clients may need this at least the first time in order to be able to play the audio. This method will be called automatically if the "autoLoad" option was set to true when calling the
CB_AudioFile#setAudioAPI
method. The audio API used will be stored in theCB_AudioFile#audioAPI
property.
When this method is called, if the "status" property of the audio API object 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 the "checkPlaying" method of the audio API object after it). After it and only if the "autoPlay" is set to true, as the "checkPlaying" method of the audio API object 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.
Although it is not recommended to do so, if this method is called when the audio API object has the "UNCHECKED" status (defined in theCB_AudioFile.UNCHECKED
constant), it will call the "checkPlaying" method of the audio API object internally.
Internally, it can use theCB_AudioFile#audioFileObjects
property as a cache.Parameters:
Name Type Argument Default Description filePath
string <optional>
CB_AudioFile#filePath
The path of the audio file or a data URI. NOTE: Only some clients with some audio APIs will support data URIs.
audioAPI
string <optional>
CB_AudioFile#audioAPI
The desired audio API to be used. If not provided, it will try to use the previously-set one (in the
CB_AudioFile#audioAPI
property). All possible ones are defined inCB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS
. For example: "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API).autoPlay
string <optional>
false If set to true, it will start playing the audio automatically (by calling the
CB_AudioFile#play
method internally) unless the "ignoreOldValues" parameter is set to false and the previous audio was playing or paused. If set to true and the "status" property of the audio API object reaches to the "UNCHECKED" status (defined in theCB_AudioFile.UNCHECKED
constant), it will also call internally the "checkPlaying" method of the audio API object before anything. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).callbackOk
function <optional>
Function with no parameters to be called when the audio has been loaded successfully, being "this" the
CB_AudioFile
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
object itself.ignoreOldValues
string <optional>
false If set to true, it will ignore the old values of the previous used audio API object. This means that it will neither continue playing if it was playing (changing the audio API on-the-fly) nor keep the paused status if it was paused nor copy its "loop" property to the new audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).forceReload
string <optional>
false Used internally as the "forceReload" parameter when calling the "load" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).- Source:
- To Do:
-
- Think about using the "forceReload" just after the "callbackError" to match the parameter order of the "load" method of all the audio API objects.
Returns:
Returns the used audio API object or null otherwise. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).- Type
- CB_AudioFile_API.WAAPI | CB_AudioFile_API.SM2 | CB_AudioFile_API.ACMP | CB_AudioFile_API.AAPI | null
-
mute( [onMute]) → {number}
-
Mutes the audio file. Internally, uses the "mute" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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
object. Used internally as the "onMute" parameter (with a wrapper function) to call the "mute" method of the audio API 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. Internally, uses the "onStop" method of the used audio API object (wrapping the given function).
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
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. Internally, uses the "pause" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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
object. Used internally as the "onPause" parameter (with a wrapper function) to call the "pause" method of the audio API object.keepPausedUnaltered
boolean <optional>
false If set to true (not recommended), the "paused" property of the audio API object will not be set to true and it will remain with its current value. Used internally as the "keepPausedUnaltered" parameter to call the "pause" method of the audio API object.
Returns:
Returns the returning value of the "pause" method of the audio API object. It returns false if the audio is already paused or it is stopped or if it cannot be paused. Returns true otherwise. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).- Type
- boolean
-
play( [startAt] [, stopAt] [, loop] [, avoidDelayedPlay] [, allowedRecursiveDelay] [, onPlayStart] [, onLoadError] [, isResume]) → {boolean|integer}
-
Plays the audio. Internally, uses the "play" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Parameters:
Name Type Argument Default Description startAt
number <optional>
0 | CB_AudioFile_API.WAAPI#lastStartAt
|CB_AudioFile_API.SM2#lastStartAt
|CB_AudioFile_API.ACMP#lastStartAt
|CB_AudioFile_API.AAPI#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 "lastStartAt" property of the used audio API object (which belongs to the "startAt" value the last time that the "play" method was called). If, even using the "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. Used internally as the "startAt" parameter to call the "play" method of the audio API object.
stopAt
number <optional>
CB_AudioFile_API.WAAPI#getDuration
() |CB_AudioFile_API.SM2#getDuration
() |CB_AudioFile_API.ACMP#getDuration
() |CB_AudioFile_API.AAPI#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 "getDuration" method of the used audio API object (which should belong to the total duration of the audio, if it was calculated correctly). Used internally as the "stopAt" parameter to call the "play" method of the audio API object.
loop
boolean <optional>
CB_AudioFile#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#onStop
method) will not be called. Used internally as the "loop" parameter to call the "play" method of the audio API object.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 of the used audio API object will be called immediately. Used internally as the "avoidDelayedPlay" parameter to call the "play" method of the audio API object.
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 "stop" method of the used audio API object 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). Used internally as the "allowedRecursiveDelay" parameter to call the "play" method of the audio API object.
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
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. Used internally as the "onPlayStart" parameter to call the "play" method of the audio API object.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
object. Used internally as the "onLoadError" parameter to call the "play" method of the audio API 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 "lastStartAt" property of the audio API object as the "startAt" parameter when it calls the "play" method again automatically (internally). Recommended for internal usage only. Used internally as the "isResume" parameter to call the "play" method of the audio API object.
Returns:
Returns the returning value of the "play" method of the audio API object. 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. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).- 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. Internally, uses the "resume" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Parameters:
Name Type Argument Default Description loop
boolean <optional>
CB_AudioFile#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#onStop
method) will not be called. Used internally as the "loop" parameter to call the "resume" method of the audio API object.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 of the used audio API object will be called immediately. Used internally as the "avoidDelayedPlay" parameter to call the "resume" method of the audio API object.
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 "stop" method of the used audio API object 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). Used internally as the "allowedRecursiveDelay" parameter to call the "resume" method of the audio API object.
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
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. Used internally as the "onPlayStart" parameter to call the "resume" method of the audio API object.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
object. Used internally as the "onLoadError" parameter to call the "resume" method of the audio API object.Returns:
Returns the returning value of the "resume" method of the audio API object. 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. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).- Type
- boolean | integer
-
setAudioAPI( [audioAPI] [, autoLoad] [, autoPlay] [, callbackOk] [, callbackError] [, ignoreOldValues] [, filePath] [, forceReload]) → {string}
-
Sets the desired audio API. This method will also be called automatically by the constructor. If the "autoLoad" parameter is set to true, it will call the
CB_AudioFile#load
method internally, changing the audio API on-the-fly, and the audio will try to continue playing if it was playing at the moment of calling this method. Check theCB_AudioFile#load
method documentation for more information. If the "autoLoad" parameter is set to true, it is recommended to be called through a user-driven event (as onClick, onTouch, etc.), as some clients may need this at least the first time in order to be able to play the audio. The audio API used will be stored in theCB_AudioFile#audioAPI
property.Parameters:
Name Type Argument Default Description audioAPI
string <optional>
CB_AudioDetector.getPreferredAPI(undefined, false, null) || CB_AudioDetector.getPreferredAPI(undefined, true, null) The desired audio API to be used. If not provided, it will try to calculate the best one for the current client by calling the
CB_AudioDetector.getPreferredAPI
function internally. Audio API support will depend on the current client being used. All possible ones are defined inCB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS
. For example: "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API). Used internally as the "audioAPI" parameter when calling theCB_AudioFile#load
method internally (only when the "autoLoad" parameter is set to true).autoLoad
string <optional>
true If set to false, it will not call the
CB_AudioFile#load
method internally and will only set theCB_AudioFile#audioAPI
property (not recommended).autoPlay
string <optional>
false Used internally as the "autoPlay" parameter when calling the
CB_AudioFile#load
method internally (only when the "autoLoad" parameter is set to true).callbackOk
function <optional>
Function with no parameters to be called when the audio has been loaded successfully, being "this" the
CB_AudioFile
object itself. Used internally as the "callbackOk" parameter when calling theCB_AudioFile#load
method internally (only when the "autoLoad" parameter is set to true).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
object itself. Used internally as the "callbackError" parameter when calling theCB_AudioFile#load
method internally (only when the "autoLoad" parameter is set to true).ignoreOldValues
string <optional>
false Used internally as the "ignoreOldValues" parameter when calling the
CB_AudioFile#load
method internally (only when the "autoLoad" parameter is set to true).filePath
string <optional>
CB_AudioFile#filePath
Used internally as the "filePath" parameter when calling the
CB_AudioFile#load
method internally (only when the "autoLoad" parameter is set to true).forceReload
string <optional>
false Used internally as the "forceReload" parameter when calling the
CB_AudioFile#load
method internally (only when the "autoLoad" parameter is set to true).- Source:
- To Do:
-
- Think about using the "forceReload" just after the "callbackError" to match the parameter order of the "load" method of all the audio API objects.
Returns:
Returns the desired audio API that has been tried to set, in upper case (successfully or not).
- Type
- string
-
setVolume( [volume] [, forceSetVolumeProperty] [, onSetVolume]) → {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). Internally, uses the "setVolume" method of the used audio API object. Possible internal audio API objects areCB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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). Used internally as the "volume" parameter to call the "setVolume" method of the audio API object.forceSetVolumeProperty
boolean <optional>
false If set to true (not recommended), it will change the "volume" property of the used audio API object even when the volume failed to be changed. Used internally as the "forceSetVolumeProperty" parameter to call the "setVolume" method of the audio API object.
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
object. Used internally as the "onSetVolume" parameter (with a wrapper function) to call the "setVolume" method of the audio API 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
-
stop( [keepStoppedUnaltered] [, avoidOnStop] [, forceOnStop]) → {boolean}
-
Stops the audio. Internally, uses the "stop" method of the used audio API object. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).Parameters:
Name Type Argument Default Description keepStoppedUnaltered
boolean <optional>
false If set to true (not recommended), the "stopped" property of the audio API object will not be set to true and it will remain with its current value. Used internally as the "keepStoppedUnaltered" parameter to call the "stop" method of the audio API object.
avoidOnStop
boolean <optional>
false If set to false and there is an "onStop" function defined (through the
CB_AudioFile#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. Used internally as the "avoidOnStop" parameter to call the "stop" method of the audio API object.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#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. Used internally as the "forceOnStop" parameter to call the "stop" method of the audio API object.Returns:
Returns the returning value of the "stop" method of the audio API object. It returns false if the stopping action cannot be performed at all (this could happen with the internal audio API 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). Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).- Type
- boolean
-
unmute( [onUnmute]) → {number}
-
Restores audio after muting it (unmutes it). Internally, uses the "unmute" method of the used audio API object which uses its own "volumeBeforeMute" property. Possible internal audio API objects are
CB_AudioFile_API.WAAPI
object for "WAAPI" (HTML5 Web Audio API),CB_AudioFile_API.SM2
object for "SM2" (SoundManager 2),CB_AudioFile_API.ACMP
object for "ACMP" (Apache Cordova Media Plugin) orCB_AudioFile_API.AAPI
object for "AAPI" (HTML5 Audio API).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
object. Used internally as the "onUnmute" parameter (with a wrapper function) to call the "unmute" method of the audio API 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#DEFAULT_OPTIONS
.autoLoadValue which will be used as the "autoLoad" parameter when calling the
CB_AudioFile#setAudioAPI
method internally (when the constructor is called).autoPlay
boolean <optional>
CB_AudioFile#DEFAULT_OPTIONS
.autoPlayValue which will be used as the "autoPlay" parameter when calling the
CB_AudioFile#setAudioAPI
method internally (when the constructor is called).loop
boolean <optional>
CB_AudioFile#DEFAULT_OPTIONS
.loopValue that will be used for the
CB_AudioFile#loop
property.volume
number <optional>
CB_AudioFile#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#volume
property.