new CB_AudioFileSpritesPool( [dataObject]) → {CB_AudioFileSpritesPool}
The constructor 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.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
dataObject |
CB_AudioFileSpritesPool.DATA_OBJECT |
<optional> |
Object with the desired data and options for the groups of audio sprites. Each group will have a |
- Source:
- To Do:
-
- Do not allow to create one object with an "id" which has already been used (unless the value is undefined, null...).
- Method getCopy and static method filterProperties (similar to the ones from
CB_GraphicSpritesandCB_GraphicSpritesScene).
Returns:
Returns a new CB_AudioFileSpritesPool object.
Members
-
<readonly> audioFileSprites :Object
-
Stores the internally-created
CB_AudioFileSpritesobjects, using the name of each property as their group ID and the value being theCB_AudioFileSpritesobject itself. Internal usage only recommended.Type:
- Object
- Default Value:
-
- {}
- Source:
-
<readonly> checkManually :boolean
-
Tells whether the
CB_AudioFileobjects must be checked automatically or not (manually). Internal usage only recommended.Type:
- boolean
- Default Value:
-
- CB_AudioFileCache.checkManually_DEFAULT
- Source:
-
<readonly> checkManuallyOnCheckingFailed :boolean
-
Tells whether the
CB_AudioFileobjects must be checked automatically or not (manually) when checking one has failed and tries to reload it. Internal usage only recommended.Type:
- boolean
- Default Value:
-
- CB_AudioFileCache.checkManuallyOnCheckingFailed_DEFAULT
- Source:
-
<readonly> checkManuallyOnNeededCreated :boolean
-
Tells whether the
CB_AudioFileobjects must be checked automatically or not (manually) when creates a newCB_AudioFileobject needed. Internal usage only recommended.Type:
- boolean
- Default Value:
-
- CB_AudioFileCache.checkManuallyOnNeededCreated_DEFAULT
- Source:
-
<readonly> checkManuallyOnPlayingFailed :boolean
-
Tells whether the
CB_AudioFileobjects must be checked automatically or not (manually) when playing one has failed and tries to reload it. Internal usage only recommended.Type:
- boolean
- Default Value:
-
- CB_AudioFileCache.checkManuallyOnPlayingFailed_DEFAULT
- Source:
-
<readonly> disableAutoLoad :boolean
-
If set to true, it will not create automatically the
CB_AudioFileobjects by calling theCB_AudioFileCache#createAudioFilesmethod internally. Internal usage only recommended.Type:
- boolean
- Default Value:
-
- false
- Source:
-
<readonly> id :string
-
Stores the identifier for the audio file sprites pool object.
Type:
- string
-
<readonly> maximumAudioFiles :integer|null
-
Maximum
CB_AudioFileobjects that are to be created internally for eachCB_AudioFileSpritesobject. If it is set to null, there will not be a maximum (it will be unlimited). If an integer is provided, it must be the same number or greater than the value set in theCB_AudioFileCache#minimumAudioFilesproperty, allowing 1 minimum. Internal usage only recommended.Type:
- integer | null
- Default Value:
-
- CB_AudioFileCache.maximumAudioFiles_DEFAULT
- Source:
-
<readonly> minimumAudioFiles :integer
-
Minimum
CB_AudioFileobjects to create internally for eachCB_AudioFileSpritesobject. It must be an integer being 1 the minimum. Internal usage only recommended.Type:
- integer
- Default Value:
-
- CB_AudioFileCache.minimumAudioFiles_DEFAULT
- Source:
-
<readonly> minimumAudioFilesFree :integer
-
New
CB_AudioFileobjects will be created internally for eachCB_AudioFileSpritesobject when the number of freeCB_AudioFileobjects reaches this limit. It must be an integer being 0 (zero) the minimum. Internal usage only recommended.Type:
- integer
- Default Value:
-
- parseInt(
CB_AudioFileCache#minimumAudioFiles* 0.25 + 0.5)
- parseInt(
- Source:
-
<readonly> newAudioFilesWhenNeeded :integer
-
Number of new
CB_AudioFileobjects to create internally for eachCB_AudioFileSpritesobject when the minimum limit of freeCB_AudioFileobjects (CB_AudioFileCache#minimumAudioFilesFree) is reached. It must be an integer being 0 (zero) the minimum. Internal usage only recommended.Type:
- integer
- Default Value:
-
- Math.min(parseInt(
CB_AudioFileCache#minimumAudioFiles* 0.1 + 0.5), 1)
- Math.min(parseInt(
- Source:
-
<readonly> onError :function
-
Desired function to be called when any kind of error happens. The first and unique parameter will be a string with the error description (if it could be determined), being "this" the current
CB_AudioFileSpritesPoolobject. If a function is set, it will always be called through theCB_AudioFileSpritesPool#errorFunctionmethod whenever the "onError" event of an internally-createdCB_AudioFileSpritesobject is fired.Type:
- function
-
<readonly> onLoad :function
-
Desired function to be called once the pool has been loaded. The first and unique parameter will be an integer with the
CB_AudioFileobjects that still need to be checked, if any, being "this" the currentCB_AudioFileSpritesPoolobject.Type:
- function
-
<readonly> preferredAPIs :array
-
Stores an array of strings with the preferred audio API or audio APIs, in order of preference. Possible audio APIs are "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API). Internal usage only recommended.
Type:
- array
- Default Value:
-
- CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS
- Source:
-
<readonly> preferredFormats :array
-
Stores an array of strings with the preferred audio format or audio formats (they can include just the format as 'audio/ogg' or also the codec as for example 'audio/ogg; codecs="vorbis"'), in order of preference. Internal usage only recommended.
Type:
- array
- Default Value:
-
- CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_FORMATS
- Source:
-
<readonly> retries :integer
-
Number of retries to try to load a
CB_AudioFileobject internally before trying to load the next possible one internally (if any). It must be an integer being 0 the minimum. Internal usage only recommended.Type:
- integer
- Default Value:
-
- CB_AudioFileCache.retries_DEFAULT
- Source:
-
<static, constant> ABORTED :integer
-
Status value for an audio file sprites pool which has been aborted. This will happen when the audio file sprites pool has been destroyed with the
CB_AudioFileSpritesPool#destructormethod. Can be used to compare the value returned by theCB_AudioFileSpritesPool#getStatusmethod. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 6
- Source:
-
<static, constant> CHECKING :integer
-
Status value for an audio file sprites pool which is being checked currently. Can be used to compare the value returned by the
CB_AudioFileSpritesPool#getStatusmethod. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 3
- Source:
-
<static, constant> FAILED :integer
-
Status value for an audio file sprites pool which failed to be loaded or failed for any other reason. Can be used to compare the value returned by the
CB_AudioFileSpritesPool#getStatusmethod. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 5
- Source:
-
<static, constant> LOADED :integer
-
Status value for an audio file sprites pool which has been loaded. Can be used to compare the value returned by the
CB_AudioFileSpritesPool#getStatusmethod. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 4
- Source:
-
<static, constant> LOADING :integer
-
Status value for an audio file sprites pool which is loading. Can be used to compare the value returned by the
CB_AudioFileSpritesPool#getStatusmethod. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 1
- Source:
-
<static, constant> UNCHECKED :integer
-
Status value for an audio file sprites pool which has not been checked yet. Can be used to compare the value returned by the
CB_AudioFileSpritesPool#getStatusmethod. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 2
- Source:
-
<static, constant> UNLOADED :integer
-
Status value for audio file sprites pool which is unloaded. Can be used to compare the value returned by the
CB_AudioFileSpritesPool#getStatusmethod. Recommended for internal usage only.Type:
- integer
- Default Value:
-
- 0
- Source:
Methods
-
cancelSoundInstance(soundInstanceId [, cancel] [, affectWithObjectAssociated]) → {boolean}
-
Cancels (to prevent it starts playing) or enables a sound instance (created by the
CB_AudioFileCache#playmethod), by its identifier. Uses theCB_AudioFileSprites#cancelSoundInstancemethod internally.Parameters:
Name Type Argument Default Description soundInstanceIdinteger Used as the "soundInstanceId" parameter when calling the
CB_AudioFileSprites#cancelSoundInstancemethod internally.cancelboolean <optional>
false Used as the "cancel" parameter when calling the
CB_AudioFileSprites#cancelSoundInstancemethod internally.affectWithObjectAssociatedboolean <optional>
false Used as the "affectWithObjectAssociated" parameter when calling the
CB_AudioFileSprites#cancelSoundInstancemethod internally.Returns:
Returns true if the sound instance has been modified or false otherwise.
- Type
- boolean
-
cancelSoundInstances( [cancel] [, affectWithObjectAssociated]) → {integer}
-
Cancels (to prevent they start playing) or enables all sound instances (created by the
CB_AudioFileCache#playmethod). Uses theCB_AudioFileSprites#cancelSoundInstancesmethod internally.Parameters:
Name Type Argument Default Description cancelboolean <optional>
false Used as the "cancel" parameter when calling the
CB_AudioFileSprites#cancelSoundInstancesmethod internally.affectWithObjectAssociatedboolean <optional>
false Used as the "affectWithObjectAssociated" parameter when calling the
CB_AudioFileSprites#cancelSoundInstancesmethod internally.Returns:
Returns the number of sound instances modified.
- Type
- integer
-
checkPlayingAll( [callbackOk] [, callbackError] [, ignoreQueue] [, ignoreStatus]) → {integer}
-
Checks whether each
CB_AudioFileobject whoseCB_AudioFile#getStatusmethod returns the "unchecked" value (which belongs to the value of theCB_AudioFile#UNCHECKEDproperty) can be played or not. After checking, if the audio can be played, the status of theCB_AudioFileobject will get the value ofCB_AudioFile.LOADED. Otherwise, if it cannot be played, the status of theCB_AudioFileobject will get the value ofCB_AudioFile.FAILED. If aCB_AudioFileobject cannot be played and it is determined necessary, it will try to reload it internally (by calling theCB_AudioFileCache#removeAudioFilemethod). It will call theCB_AudioFileCache#clearAudioFilesmethod internally after finishing each call to theCB_AudioFileSprites#checkPlayingAllmethod. Uses theCB_AudioFileSprites#checkPlayingAllmethod internally. Recommended to be called through a user-driven event (as onClick, onTouch, etc.).Parameters:
Name Type Argument Default Description callbackOkCB_AudioFileSpritesPool.checkPlayingAll_CALLBACK_OK <optional>
A function which will be called if all the
CB_AudioFileobjects whoseCB_AudioFile#getStatusmethod returned the "unchecked" value (which belongs to the value of theCB_AudioFile#UNCHECKEDproperty) could finally be checked successfully and all can be played, being "this" theCB_AudioFileSpritesPoolobject itself.callbackErrorCB_AudioFileSpritesPool.checkPlayingAll_CALLBACK_ERROR <optional>
A function which will be called if not all the
CB_AudioFileobjects whoseCB_AudioFile#getStatusmethod returned the "unchecked" value (which belongs to the value of theCB_AudioFile#UNCHECKEDproperty) could finally be checked successfully and any cannot be played, being "this" theCB_AudioFileSpritesPoolobject itself. This function will be called immediately if the method was previously called and it is still running currently.ignoreQueueboolean <optional>
false Used as the "ignoreQueue" parameter when calling the
CB_AudioFileSprites#checkPlayingAllmethod internally.ignoreStatusboolean <optional>
false If it is set to false and the sprites pool object is loaded (the
CB_AudioFileSpritesPool#getStatusmethod returns the value set in theCB_AudioFileSpritesPool.LOADEDproperty), it will exit returning an error. Otherwise, if it is set to true, it will ignore the current sprites pool object status.Returns:
Returns the number of
CB_AudioFileobjects whose status belonged to the "unchecked" value (the value of theCB_AudioFile#UNCHECKEDproperty) before the execution of this method. It will return 0 (zero) if the method is tried to be executed while there is another previous call of it still running. It will also return 0 (zero) if the status of audio sprites pool is neither loaded (theCB_AudioFileSpritesPool#getStatusmethod does not returns the value set in theCB_AudioFileSpritesPool.LOADEDproperty) nor unchecked (theCB_AudioFileSpritesPool#statusmethod does not return the value set in theCB_AudioFileSpritesPool.UNCHECKEDproperty).- Type
- integer
-
clearAudioFiles( [avoidCallingCheckCacheLoaded]) → {array}
-
Cleans the arrays of the
CB_AudioFileobjects (taking off the undefined or null ones) which is in theCB_AudioFileCache#audioFilesproperty used by eachCB_AudioFileSpritesobject, just keeping the valid ones and clearing (destroying and removing) the others. For performance purposes. Uses theCB_AudioFileSprites#clearAudioFilesmethod internally. Internal usage only recommended.Parameters:
Name Type Argument Default Description avoidCallingCheckCacheLoadedboolean <optional>
false Used as the "avoidCallingCheckCacheLoaded" parameter when calling the
CB_AudioFileSprites#clearAudioFilesmethod internally.Returns:
Returns an object whose each property name is the sprites group ID and each value is the returning value of calling internally the
CB_AudioFileSprites#clearAudioFilesmethod.- Type
- array
-
clearSoundInstances( [clearWithObjectAssociated]) → {integer}
-
Clears the sound instances (created by the
CB_AudioFileCache#playmethod) which have been cancelled. Uses theCB_AudioFileSprites#clearSoundInstancesmethod internally.Parameters:
Name Type Argument Default Description clearWithObjectAssociatedboolean <optional>
false Used as the "clearWithObjectAssociated" parameter when calling the
CB_AudioFileSprites#clearSoundInstancesmethod internally.Returns:
Returns the number of cleared sound instances.
- Type
- integer
-
destroyAll( [stopSounds]) → {integer}
-
Destroys all the
CB_AudioFileobjects and frees memory, by callingCB_AudioFile#destructor(stopSounds, false, true). Uses theCB_AudioFileSprites#destroyAllmethod internally.Parameters:
Name Type Argument Default Description stopSoundsboolean <optional>
false Used as the "stopSounds" parameter when calling the
CB_AudioFileSprites#destroyAllmethod internally.Returns:
Returns the number of
CB_AudioFileobjects whoseCB_AudioFile#destructorhas been called.- Type
- integer
-
destructor( [stopSounds] [, preventAbortedStatus])
-
Destroys the audio file sprites pool object (removing all sprites, etc.), including the internal audio file sprites objects, and frees memory. By default, unless the "preventAbortedStatus" is set to true, sets the current status of all the
CB_AudioFileCacheobjects as ABORTED (CB_AudioFileCache.ABORTEDvalue). Internally, calls theCB_AudioFileSprites#destructormethod of all the internally-createdCB_AudioFileSpritesobjects.Parameters:
Name Type Argument Default Description stopSoundsboolean <optional>
false Used as the "stopSounds" parameter when calling internally the
CB_AudioFileSprites#destructormethod of all the internally-createdCB_AudioFileSpritesobjects.preventAbortedStatusboolean <optional>
false If set to true (not recommended), it will not assign the status of "ABORTED" (it will not set the
CB_AudioFileSpritesPool#_abortedproperty to true}. Used as the "preventAbortedStatus" parameter when calling internally theCB_AudioFileSprites#destructormethod of all the internally-createdCB_AudioFileSpritesobjects. -
errorFunction( [message] [, ignorePreviousExecution]) → {boolean}
-
Calls the error function which should be set in the
CB_AudioFileSprites#onErrorproperty (if any), being "this" theCB_AudioFileSpritesPoolobject itself. Internal usage only recommended.Parameters:
Name Type Argument Default Description messagestring <optional>
The message describing the error that will be sent to the set
CB_AudioFileSprites#onErrorfunction (if any) as the first and unique parameter.ignorePreviousExecutionboolean <optional>
false If it is set to false, the function set in the
CB_AudioFileSprites#onErrorproperty (if any) will only be called if it was not executed previously.Returns:
Returns true if the
CB_AudioFileSprites#onErrorfunction could be called or false otherwise.- Type
- boolean
-
executeAll()
-
Alias for
CB_AudioFileSpritesPool#executeFunctionAll. -
executeAllSprites()
-
executeAllSubSprites()
-
Alias for
CB_AudioFileSpritesPool#executeFunctionAllSubSprites.- Source:
- See:
-
CB_AudioFileSpritesPool#executeFunctionAllSubSprites
-
executeFunctionAll(functionEach [, delayBetweenEach] [, audioFiles] [, returnArrayOfSetTimeoutsArray] [, delayBetweenEachAffectsFirst] [, functionFinish]) → {integer|array}
-
Performs a desired action, using the provided function, on all the existing
CB_AudioFileobjects or on the desired ones (if provided). Uses theCB_AudioFileSprites#executeFunctionAllmethod internally.Parameters:
Name Type Argument Default Description functionEachCB_Arrays.CB_Arrays.executeFunctionAll_ON_LOOP_CALLBACK Used as the "functionEach" parameter when calling the
CB_AudioFileSprites#executeFunctionAllmethod internally.delayBetweenEachnumber | CB_Arrays.executeFunctionAll_ON_LOOP_CALLBACK <optional>
0 Used as the "delayBetweenEach" parameter when calling the
CB_AudioFileSprites#executeFunctionAllmethod internally. Note that each call to theCB_AudioFileSprites#executeFunctionAllmethod will be performed sequentially one after the other, without adding a delay.audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#executeFunctionAllmethod internally.returnArrayOfSetTimeoutsArrayboolean <optional>
false If it is set to false, it will return the number of calls to the "functionEach" function that were performed. Otherwise, if it is set to true, it will return a numeric array and each value (which will belong to each sprites group) will be another numeric array with a
CB_AudioFileCache.executeFunctionAll_OBJECTobject for eachCB_AudioFileof that sprites group.delayBetweenEachAffectsFirstboolean <optional>
false Used as the "delayBetweenEachAffectsFirst" parameter when calling the
CB_AudioFileSprites#executeFunctionAllmethod internally. Note that each call to theCB_AudioFileSprites#executeFunctionAllmethod will be performed sequentially one after the other, without adding a delay.functionFinishCB_AudioFileSpritesPool.executeFunctionAll_ON_FINISH_CALLBACK <optional>
Function that will be called for when it has finished looping all the items. The first parameter will be the array containing all the items which were looped, the second parameter will be the number of times that the "functionEach" callback was called (the most likely, matches the number of elements unless they are undefined or null), and the third parameter will be the maximum "delay" used, being "this" the array itself.
- Source:
- To Do:
-
- Think about consider executing only one by one (now it will loop
CB_AudioFileobjects from different sprites groups simultaneously).
- Think about consider executing only one by one (now it will loop
Returns:
If the "returnArrayOfSetTimeoutsArray" parameter is set to false, it will return the number of calls to the "functionEach" function that were performed. Otherwise, if the "returnArrayOfSetTimeoutsArray" is set to true, it will return a numeric array and each value will be another numeric array with a
CB_AudioFileCache.executeFunctionAll_OBJECTobject for eachCB_AudioFilegiven. Note that if a value greater than 0 (zero) for the "delayBetweenEach" parameter has been provided, perhaps not all calls of the "functionEach" function will have been performed yet when exiting this method because of the asynchronous nature of the setTimeout function.- Type
- integer | array
-
executeFunctionAllSprites(functionEach [, delayBetweenEach] [, includeWithoutSpriteAssociated] [, avoidCancelled] [, delayBetweenEachAffectsFirst] [, functionFinish]) → {integer}
-
Executes a desired function for all the
CB_AudioFileobjects used by all the sound instances currently created of each sprite group. It calls theCB_AudioFileSprites#executeFunctionAllSpritesmethod internally.Parameters:
Name Type Argument Default Description functionEachCB_Arrays.executeFunctionAll_ON_LOOP_CALLBACK Used as the "functionEach" parameter when calling the
CB_AudioFileSprites#executeFunctionAllSpritesmethod internally.delayBetweenEachnumber | CB_Arrays.executeFunctionAll_ON_LOOP_CALLBACK <optional>
0 Used as the "delayBetweenEach" parameter when calling the
CB_AudioFileSprites#executeFunctionAllSpritesmethod internally. Note that each call to theCB_AudioFileSprites#executeFunctionAllSpritesmethod will be performed sequentially one after the other, without adding a delay.includeWithoutSpriteAssociatedboolean <optional>
false Used as the "includeWithoutSpriteAssociated" parameter when calling the
CB_AudioFileSprites#executeFunctionAllSpritesmethod internally.avoidCancelledboolean <optional>
false Used as the "avoidCancelled" parameter when calling the
CB_AudioFileSprites#executeFunctionAllSpritesmethod internally.delayBetweenEachAffectsFirstboolean <optional>
false Used as the "delayBetweenEachAffectsFirst" parameter when calling the
CB_AudioFileSprites#executeFunctionAllSpritesmethod internally. Internal usage only recommended. Note that each call to theCB_AudioFileSprites#executeFunctionAllSpritesmethod will be performed sequentially one after the other, without adding a delay.functionFinishCB_AudioFileSpritesPool.executeFunctionAll_ON_FINISH_CALLBACK <optional>
Function that will be called for when it has finished looping all the items. The first parameter will be the array containing all the items which were looped, the second parameter will be the number of times that the "functionEach" callback was called (the most likely, matches the number of elements unless they are undefined or null), and the third parameter will be the maximum "delay" used, being "this" the array itself.
- Source:
- To Do:
-
- Think about implementing a "returnSetTimeoutsArray" or similar (as in
CB_AudioFileSprites#executeFunctionAllSprites). - Think about consider executing only one by one (now it will loop
CB_AudioFileobjects from different sprites groups simultaneously).
- Think about implementing a "returnSetTimeoutsArray" or similar (as in
Returns:
It will return the number of calls to the "functionEach" function that were performed (which should be the same number as the
CB_AudioFileobjects used by the sound instances that belong to the sprites of each sprites group). Note that if a value greater than 0 (zero) for the "delayBetweenEach" parameter has been provided, perhaps not all calls of the "functionEach" function will have been performed yet when exiting this method because of the asynchronous nature of the setTimeout function.- Type
- integer
-
forEach()
-
Alias for
CB_AudioFileSpritesPool#executeFunctionAll. -
forEachSprite()
-
forEachSubSprite()
-
Alias for
CB_AudioFileSpritesPool#executeFunctionAllSubSprites.- Source:
- See:
-
CB_AudioFileSpritesPool#executeFunctionAllSubSprites
-
getAudioFileBySoundInstanceId(soundInstanceId [, avoidCancelled]) → {CB_AudioFile|null}
-
Gets the
CB_AudioFileobject associated to a given sound instance ID (created by theCB_AudioFileCache#playmethod), if any, or null otherwise. Uses theCB_AudioFileSprites#getAudioFileBySoundInstanceIdmethod internally.Parameters:
Name Type Argument Default Description soundInstanceIdinteger Used as the "soundInstanceId" parameter when calling the
CB_AudioFileSprites#getAudioFileBySoundInstanceIdmethod internally.avoidCancelledboolean <optional>
false Used as the "avoidCancelled" parameter when calling the
CB_AudioFileSprites#getAudioFileBySoundInstanceIdmethod internally.Returns:
Returns the
CB_AudioFileobject associated to a given sound instance ID, if any, or null otherwise.- Type
- CB_AudioFile | null
-
getAudioFiles( [copy] [, oneDimension]) → {Object|array}
-
Gets an object with arrays or a one-dimension array with all the
CB_AudioFileobjects. Uses theCB_AudioFileSprites#getAudioFilesmethod internally.Parameters:
Name Type Argument Default Description copyboolean <optional>
false Used as the "copy" parameter when calling the
CB_AudioFileSprites#getAudioFilesmethod internally.oneDimensionboolean <optional>
false If it is set to true, the method will return an array with all the
CB_AudioFileobjects. Otherwise, if it is set to false, the method will return an object whose property names will be the ID of each sprites group and their value will be an array with all theCB_AudioFileobjects that belong to that sprites group.Returns:
If the "oneDimension" parameter is set to true, returns an array with all the
CB_AudioFileobjects. Otherwise, if the "oneDimension" parameter is set to false, it will return an object whose property names will be the ID of each sprites group and their value will be an array with all theCB_AudioFileobjects that belong to that sprites group.- Type
- Object | array
-
getAudioFilesBusy( [oneDimension]) → {Object|array}
-
Gets an object with arrays or a one-dimension array with the busy
CB_AudioFileobjects (the objects which are not available and ready to use). Uses theCB_AudioFileSprites#getAudioFilesBusymethod internally.Parameters:
Name Type Argument Default Description oneDimensionboolean <optional>
false If it is set to true, the method will return an array with the busy
CB_AudioFileobjects. Otherwise, if it is set to false, the method will return an object whose property names will be the ID of each sprites group and their value will be an array with the busyCB_AudioFileobjects that belong to that sprites group.Returns:
If the "oneDimension" parameter is set to true, returns an array with the busy
CB_AudioFileobjects. Otherwise, if the "oneDimension" parameter is set to false, it will return an object whose property names will be the ID of each sprites group and their value will be an array with the busyCB_AudioFileobjects that belong to that sprites group.- Type
- Object | array
-
getAudioFilesFree( [oneDimension]) → {Object|array}
-
Gets an object with arrays or a one-dimension array with the free
CB_AudioFileobjects (the objects which are available and ready to use). Uses theCB_AudioFileSprites#getAudioFilesFreemethod internally.Parameters:
Name Type Argument Default Description oneDimensionboolean <optional>
false If it is set to true, the method will return an array with the free
CB_AudioFileobjects. Otherwise, if it is set to false, the method will return an object whose property names will be the ID of each sprites group and their value will be an array with the freeCB_AudioFileobjects that belong to that sprites group.Returns:
If the "oneDimension" parameter is set to true, returns an array with the free
CB_AudioFileobjects. Otherwise, if the "oneDimension" parameter is set to false, it will return an object whose property names will be the ID of each sprites group and their value will be an array with the freeCB_AudioFileobjects that belong to that sprites group.- Type
- Object | array
-
getAudioFilesFreeNumber() → {integer}
-
Tells the current number of free
CB_AudioFileobjects (the number of objects which are available and ready to use). Uses theCB_AudioFileSprites#getAudioFilesFreeNumbermethod internally.Returns:
Returns the current number of free
CB_AudioFileobjects (the number of objects which are available and ready to use).- Type
- integer
-
getAudioFilesNumber( [real]) → {integer}
-
Tells the number of
CB_AudioFileobjects created. Uses theCB_AudioFileSprites#getAudioFilesNumbermethod internally.Parameters:
Name Type Argument Default Description realboolean <optional>
false Used as the "real" parameter when calling the
CB_AudioFileSprites#getAudioFilesNumbermethod internally.Returns:
Returns the number of
CB_AudioFileobjects created.- Type
- integer
-
getAudioFilesUsed( [oneDimension] [, includeWithoutSpriteAssociated] [, avoidCancelled]) → {CB_AudioFileSprites.getAudioFilesUsed_OBJECT|array}
-
Returns the
CB_AudioFileobjects used by all the sounds instances of all the sprites groups.Parameters:
Name Type Argument Default Description oneDimensionboolean <optional>
false If set to false, it will return an object whose property names will be the ID of each sprites group and their value will be the an object whose property names are the sprite identifiers (including the "_WITHOUT_SPRITE_ASSOCIATED" property for sound instances without a sprite associated, if the "includeWithoutSpriteAssociated" is set to true) and their value will be a numeric array with the
CB_AudioFileobjects used. Otherwise, if set to true, it will return a numeric array with theCB_AudioFileobjects used (if the "includeWithoutSpriteAssociated" parameter is set to true, it will also contain theCB_AudioFileobjects whose sound instance ID is not associated to any sprite).includeWithoutSpriteAssociatedboolean <optional>
false If set to true, it will also return the
CB_AudioFileobjects whose sound instance ID is not associated to any sprite. Used as the "includeWithoutSpriteAssociated" parameter when calling theCB_AudioFileSprites#getAudioFilesUsedmethod internally.avoidCancelledboolean <optional>
false If set to true, it will not return the
CB_AudioFileobjects whose sound instance has been cancelled. Used as the "avoidCancelled" parameter when calling theCB_AudioFileSprites#getAudioFilesUsedmethod internally.Returns:
Returns the
CB_AudioFileobjects used by all the sounds instances of all the sprites groups. If the "oneDimension" parameter is set to false, it will return aCB_AudioFileSpritesPool.getAudioFilesUsed_OBJECTobject whose property names will be the ID of each sprites group and their value will be aCB_AudioFileSprites.getAudioFilesUsed_OBJECTobject whose property names are the sprite identifiers (including the "_WITHOUT_SPRITE_ASSOCIATED" property for sound instances without a sprite associated, if the "includeWithoutSpriteAssociated" is set to true) and their value will be a numeric array with theCB_AudioFileobjects used. Otherwise, if the "oneDimension" parameter set to true, it will return a numeric array with theCB_AudioFileobjects used (if the "includeWithoutSpriteAssociated" parameter is set to true, it will also contain theCB_AudioFileobjects whose sound instance ID is not associated to any sprite).- Type
- CB_AudioFileSprites.getAudioFilesUsed_OBJECT | array
-
getProgress( [countLoadedObjects] [, alsoUncheckedAndCheckingObjects]) → {number}
-
Returns a number representing the percentage of the loading progress for the audio sprites pool object (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. Uses the
CB_AudioFileSprites#getProgressmethod internally.Parameters:
Name Type Argument Default Description countLoadedObjectsboolean <optional>
false Used as the "countLoadedObjects" parameter when calling the
CB_AudioFileSprites#getProgressmethod internally.alsoUncheckedAndCheckingObjectsboolean <optional>
false Used as the "alsoUncheckedAndCheckingObjects" parameter when calling the
CB_AudioFileSprites#getProgressmethod internally.Returns:
Returns a number representing the percentage of the loading progress for the audio sprites pool object (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
-
getSoundInstancesId( [oneDimension] [, includeWithoutSpriteAssociated]) → {Object|array}
-
Returns the sound instances (their ID) used (stored in the
CB_AudioFileSprites#spriteSoundInstancesproperty of eachCB_AudioFileSpritesobject).Parameters:
Name Type Argument Default Description oneDimensionboolean <optional>
false If set to false, it will return an object whose property names will be the ID of each sprites group and their value will be the
CB_AudioFileSprites#spriteSoundInstancesproperty of eachCB_AudioFileSpritesobject (which includes the "_WITHOUT_SPRITE_ASSOCIATED" property for sound instances without a sprite associated) which belongs to that sprites group. Otherwise, if it is set to true, it will return a numeric array whose values are the sound instance IDs.includeWithoutSpriteAssociatedboolean <optional>
false If set to true, it will also return the sound instance identifiers which are not associated to any sprite. Used as the "includeWithoutSpriteAssociated" parameter when calling the
CB_AudioFileSprites#getSoundInstancesIdmethod internally. Only used when the "oneDimension" parameter is set to true.Returns:
Returns the sound instances (their ID) used (stored in the
CB_AudioFileSprites#spriteSoundInstancesproperty). If the "oneDimension" parameter is set to false, it will return an object whose property names will be the ID of each sprites group and their value will be theCB_AudioFileSprites#spriteSoundInstancesproperty of eachCB_AudioFileSpritesobject (which includes the "_WITHOUT_SPRITE_ASSOCIATED" property for sound instances without a sprite associated) which belongs to that sprites group. If the "oneDimension" parameter is set to true, it will return a numeric array whose values are the sound instance identifiers (if the "includeWithoutSpriteAssociated" parameter it set to true, it will also include the sound instances which are not associated to any sprite).- Type
- Object | array
-
getSprites( [includeWithoutSpriteAssociated] [, orderBySpritesGroup]) → {CB_AudioFileSprites.SPRITES_OBJECT|Object}
-
Returns an object with the sprites (and includes "_WITHOUT_SPRITE_ASSOCIATED" if we want to). Internally, uses the
CB_AudioFileSprites#getSpritesmethod.Parameters:
Name Type Argument Default Description includeWithoutSpriteAssociatedboolean <optional>
false If set to true, the returning object will also contain a property called "_WITHOUT_SPRITE_ASSOCIATED" whose value will be an empty object (unless the "orderBySpritesGroup" parameter is set to true and the property existed before in the object stored in the
CB_AudioFileSprites#spritesproperty and had a value which is not an empty object). If set to false and the "orderBySpritesGroup" parameter is also set to false, the returning object will not contain the "_WITHOUT_SPRITE_ASSOCIATED" property. If set to false and the "orderBySpritesGroup" parameter is set to true, the returning object will not contain the "_WITHOUT_SPRITE_ASSOCIATED" property unless the property existed before in the object stored in theCB_AudioFileSprites#spritesproperty.orderBySpritesGroupboolean <optional>
false If set to false, it will return a
CB_AudioFileSprites.SPRITES_OBJECTobject whose properties will be the ID of each sprite (each sprite ID should be unique) and their value will be aCB_AudioFileSprites.SPRITE_OBJECTobject. If set to true, it will return an object whose properties will be the ID of each sprites group and the value will be aCB_AudioFileSprites.SPRITES_OBJECTobject which will include its sprites.Returns:
If the "orderBySpritesGroup" is set to false, it will return a
CB_AudioFileSprites.SPRITES_OBJECTobject whose properties will be the ID of each sprite (each sprite ID should be unique) and their value will be aCB_AudioFileSprites.SPRITE_OBJECTobject. If the "orderBySpritesGroup" is set to true, it will return an object whose properties will be the ID of each sprites group and the value will be aCB_AudioFileSprites.SPRITES_OBJECTobject which will include its sprites.- Type
- CB_AudioFileSprites.SPRITES_OBJECT | Object
-
getSpritesGroup(spritesGroupId [, withoutChecking]) → {CB_AudioFileSprites|undefined|*|null}
-
Returns a sprites group (the
CB_AudioFileSpritesobject) by its ID.Parameters:
Name Type Argument Default Description spritesGroupIdstring The identifier for the sprites group.
withoutCheckingboolean <optional>
false If set to true and the sprites group cannot be found, the method will return undefined (or whatever is stored by the given ID) instead of null.
Returns:
Returns null if the "withoutChecking" parameter is set to true and the sprites group cannot be found. Otherwise, it will return what is stored internally by the given ID which can be a
CB_AudioFileSpritesobject if found or undefined (or whatever is stored by the given ID) if not found.- Type
- CB_AudioFileSprites | undefined | * | null
-
getSpritesGroups() → {Object}
-
Returns an object with the sprites groups (all the internally-created
CB_AudioFileSpritesobjects), being the name of each property their group ID and the value being theCB_AudioFileSpritesobject itself. Internally, it just returns theCB_AudioFileSpritesPool#audioFileSpritesproperty.Returns:
Returns an object with the sprites groups (all the internally-created
CB_AudioFileSpritesobjects), being the name of each property their group ID and the value being theCB_AudioFileSpritesobject itself. Internally, it just returns theCB_AudioFileSpritesPool#audioFileSpritesproperty.- Type
- Object
-
getStatus() → {number}
-
Gets the current status of the audio file sprites pool object. Uses the
CB_AudioFileSprites#getStatusmethod internally.Returns:
Returns the current status of the audio file sprites pool object. It is a number, affected by the returning value of the
CB_AudioFileSprites#getStatusmethod of eachCB_AudioFileSpritesobject used internally, which should match the value of theCB_AudioFileCache.UNLOADED(still unloaded),CB_AudioFileCache.LOADING(loading),CB_AudioFileCache.UNCHECKED(not checked by calling theCB_AudioFileCache#checkPlayingAllmethod yet),CB_AudioFileCache.CHECKING(being checked by theCB_AudioFileCache#checkPlayingAllmethod),CB_AudioFileCache.LOADED(loaded),CB_AudioFileCache.FAILED(failed loading or failed to play or by any other reason) orCB_AudioFileCache.ABORTED(aborted because it was destroyed with the "destructor" method) property.- Type
- number
-
getStatusString() → {string}
-
Gets the current status of the audio file sprites pool object, as a string.
Returns:
Returns the current status of the audio file sprites pool object, as a string. Possible return values are "UNLOADED", "LOADING", "UNCHECKED", "CHECKING", "LOADED", "FAILED", "ABORTED" or "UNKNOWN (UNKNOWN_STATUS)" (where "UNKNOWN_STATUS" will be a returning value from the
CB_AudioFileSpritesPool#getStatusmethod not recognized as any possible status).- Type
- string
-
insertSpritesGroup(spritesGroupId [, dataObject] [, avoidCheckingLoaded]) → {boolean}
-
Inserts the given sprites group to the audio file sprites pool object.
Parameters:
Name Type Argument Default Description spritesGroupIdstring The identifier for the sprites group.
dataObjectCB_AudioFileSprites.DATA_OBJECT <optional>
Object with the data of the sprites group. Optional but recommended.
avoidCheckingLoadedboolean <optional>
false If set to true, it will not check whether all sprites groups has been loaded after inserting the desired one. This is done internally by the
CB_AudioFileSpritesPool#_checkSpritesGroupsLoadedmethod which will fire theCB_AudioFileSpritesPool#onLoadfunction (if any).Returns:
Returns true if the sprites group has been inserted or false otherwise.
- Type
- boolean
-
insertSpritesGroups(sprites) → {integer}
-
Inserts the given sprites groups.
Parameters:
Name Type Description spritesCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECT Object with the desired sprites groups.
Returns:
Returns the number of sprites groups inserted.
- Type
- integer
-
isAudioFileFree(id) → {boolean}
-
Tells whether a desired
CB_AudioFileobject is free (it is in theCB_AudioFileCache#audioFilesFreeproperty of anyCB_AudioFileSpritesobject) or not, by its identifier. A freeCB_AudioFileobject is an object which is not being used and it is available to be used. Uses theCB_AudioFileSprites#isAudioFileFreemethod internally.Parameters:
Name Type Description idstring Used as the "id" parameter when calling the
CB_AudioFileSprites#isAudioFileFreemethod internally.Returns:
Returns whether a desired
CB_AudioFileobject is free (it is in theCB_AudioFileCache#audioFilesFreeproperty of anyCB_AudioFileSpritesobject) or not, by its identifier. A freeCB_AudioFileobject is an object which is not being used and it is available to be used.- Type
- boolean
-
isPlaying() → {boolean}
-
Tells whether any of the
CB_AudioFileobjects is playing or not. Uses theCB_AudioFileSprites#isPlayingmethod internally.Returns:
Returns whether any of the
CB_AudioFileobjects is playing or not.- Type
- boolean
-
load(dataObject) → {CB_AudioFileSpritesPool|null}
-
Loads the audio file sprites pool with the desired data given. This method is called by the constructor automatically. 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.
Parameters:
Name Type Description dataObjectCB_AudioFileSpritesPool.DATA_OBJECT Object with the desired data and options for the audio file sprites.
Returns:
If a "dataObject" is given, it returns the current
CB_AudioFileSpritesPoolobject. Otherwise, it returns null.- Type
- CB_AudioFileSpritesPool | null
-
muteAll( [onMute] [, audioFiles]) → {integer}
-
Mutes all the existing
CB_AudioFileobjects or the desired ones (if provided). Uses theCB_AudioFileSprites#muteAllmethod internally.Parameters:
Name Type Argument Default Description onMutefunction <optional>
Used as the "onMute" parameter when calling the
CB_AudioFileSprites#muteAllmethod internally.audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#muteAllmethod internally.Returns:
Returns the number of calls to the
CB_AudioFile#mutemethod that were performed.- Type
- integer
-
pauseAll( [onPause] [, audioFiles]) → {integer}
-
Tries to pause all the existing
CB_AudioFileobjects or the desired ones (if provided), which are being played, by calling theirCB_AudioFile#pausemethod internally. Uses theCB_AudioFileSprites#pauseAllmethod internally.Parameters:
Name Type Argument Default Description onPausefunction <optional>
Used as the "onPause" parameter when calling the
CB_AudioFileSprites#pauseAllmethod internally.audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#pauseAllmethod internally.Returns:
Returns the number of calls to the
CB_AudioFile#pausemethod that were performed.- Type
- integer
-
playAll( [startAt] [, stopAt] [, loop] [, volume] [, avoidDelayedPlay] [, allowedRecursiveDelay] [, onPlayStart] [, onStop] [, includingPlaying]) → {integer}
-
Tries to play all the
CB_AudioFileobjects by calling theirCB_AudioFile#playmethod internally. If aCB_AudioFileobject cannot be played and it is determined necessary, it will try to reload it internally (by calling theCB_AudioFileCache#removeAudioFilemethod). Uses theCB_AudioFileSprites#playAllmethod internally.Parameters:
Name Type Argument Default Description startAtnumber <optional>
0 | CB_AudioFile_API.WAAPI#lastStartAt|CB_AudioFile_API.SM2#lastStartAt|CB_AudioFile_API.ACMP#lastStartAt|CB_AudioFile_API.AAPI#lastStartAt| stopAtUsed as the "startAt" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.stopAtnumber <optional>
CB_AudioFile_API.WAAPI#getDuration() |CB_AudioFile_API.SM2#getDuration() |CB_AudioFile_API.ACMP#getDuration() |CB_AudioFile_API.AAPI#getDuration()Used as the "stopAt" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.loopboolean <optional>
CB_AudioFile#loopUsed as the "loop" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.volumenumber <optional>
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_USE_SPEAKER_VOLUME_AS_DEFAULT ? CB_Speaker.getVolume() : CB_Configuration.CrossBase.CB_Speaker_DEFAULT_VOLUME Used as the "volume" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.avoidDelayedPlayboolean <optional>
false Used as the "avoidDelayedPlay" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.allowedRecursiveDelayboolean <optional>
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_ALLOWED_RECURSIVE_DELAY_DEFAULTUsed as the "allowedRecursiveDelay" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.onPlayStartfunction <optional>
Used as the "onPlayStart" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.onStopfunction <optional>
Used as the "onStop" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.includingPlayingboolean <optional>
false Used as the "includingPlaying" parameter when calling the
CB_AudioFileSprites#playAllmethod internally.Returns:
Returns the number of
CB_AudioFileobjects whoseCB_AudioFile#playmethod did not return the value of "-1" (this does not mean necessarily that they could be played successfully).- Type
- integer
-
playAndStopAll( [includingPlaying] [, delayBeforeStop]) → {integer}
-
Plays silently and stops all
CB_AudioFileobjects after a desired time. It can be useful for some clients which need theCB_AudioFile#playmethod to be called through a user-driven event (as onClick, onTouch, etc.). Internally, it callsCB_AudioFileCache#playAll(0, null, false, 0, true, null, null, null, includingPlaying) and, after a desired delay, calls theCB_AudioFileCache#stopAllmethod. Uses theCB_AudioFileSprites#playAndStopAllmethod internally.Parameters:
Name Type Argument Default Description includingPlayingboolean <optional>
false Used as the "includingPlaying" parameter when calling the
CB_AudioFileSprites#playAndStopAllmethod internally.delayBeforeStopnumber <optional>
100 Used as the "delayBeforeStop" parameter when calling the
CB_AudioFileSprites#playAndStopAllmethod internally.Returns:
Returns the number of
CB_AudioFileobjects whoseCB_AudioFile#playmethod did not return the value of "-1" (this does not mean necessarily that they could be played successfully).- Type
- integer
-
purge(desiredNumber [, setAsMinimumAudioFiles] [, includePlaying] [, stopSounds] [, statuses]) → {integer}
-
Tries to purge the audio file cache of each
CB_AudioFileSpritesobject until it reaches a desired number ofCB_AudioFileobjects internally (set in theCB_AudioFileCache#audioFilesproperty), by removing and destroying some of the currentCB_AudioFileobjects. Note that the desired number is for eachCB_AudioFileSpritesobject and not a global number. For performance purposes. Uses theCB_AudioFileSprites#purgemethod internally.Parameters:
Name Type Argument Default Description desiredNumberinteger Used as the "desiredNumber" parameter when calling the
CB_AudioFileSprites#purgemethod internally. Note that the desired number is for eachCB_AudioFileSpritesobject and not a global number.setAsMinimumAudioFilesboolean <optional>
false Used as the "setAsMinimumAudioFiles" parameter when calling the
CB_AudioFileSprites#purgemethod internally.includePlayingboolean <optional>
false Used as the "includePlaying" parameter when calling the
CB_AudioFileSprites#purgemethod internally.stopSoundsboolean <optional>
false Used as the "stopSounds" parameter when calling the
CB_AudioFileSprites#purgemethod internally.statusesarray <optional>
Array( CB_AudioFile.LOADING,CB_AudioFile.UNCHECKED,CB_AudioFile.CHECKING,CB_AudioFile.LOADED)Used as the "statuses" parameter when calling the
CB_AudioFileSprites#purgemethod internally.Returns:
Returns the number of
CB_AudioFileobjects removed.- Type
- integer
-
removeSpritesGroup(spritesGroupId [, destroy] [, stopSounds] [, preventAbortedStatus]) → {boolean}
-
Removes a sprites group by its ID.
Parameters:
Name Type Argument Default Description spritesGroupIdstring The identifier for the sprites group.
destroyboolean <optional>
false If set to true, it will call the
CB_AudioFileSprites#destructormethod of theCB_AudioFileSpritesobject which belongs to the desired sprites group.stopSoundsboolean <optional>
false If the "destroy" parameter is set to false, this parameter will be ignored. Used as the "stopSound" parameter when calling internally the
CB_AudioFileSprites#destructormethod of theCB_AudioFileSpritesobject which belongs to the desired sprites group.preventAbortedStatusboolean <optional>
false If the "destroy" parameter is set to false, this parameter will be ignored. Used as the "preventAbortedStatus" parameter when calling internally the
CB_AudioFileSprites#destructormethod of theCB_AudioFileSpritesobject which belongs to the desired sprites group.Returns:
Returns true if the sprites group has been deleted or false otherwise.
- Type
- boolean
-
removeSpritesGroups()
-
Removes all the sprites groups (
CB_AudioFileSpritesobjects) by clearing theCB_AudioFileSpritesPool#audioFileSpritesproperty. -
resumeAll( [loop] [, allowedRecursiveDelay] [, allowedRecursiveDelaySkipping] [, onPlayStart] [, onStop] [, audioFiles] [, spriteId]) → {Object}
-
Resumes all the existing
CB_AudioFileobjects or the desired ones (if provided), which are paused (and not stopped). Can be focused on just one sprite ID if desired. Uses theCB_AudioFileSprites#resumeAllmethod internally. Internal usage only recommended. To resume a sprite, better use theCB_AudioFileSprites#resumeSpritemethod instead.Parameters:
Name Type Argument Default Description loopboolean <optional>
CB_AudioFile#loopUsed as the "loop" parameter when calling the
CB_AudioFileSprites#resumeAllmethod internally.allowedRecursiveDelayboolean <optional>
CB_Configuration.CrossBase.CB_AudioFile_AudioFileCache_ALLOWED_RECURSIVE_DELAY_DEFAULTUsed as the "allowedRecursiveDelay" parameter when calling the
CB_AudioFileSprites#resumeAllmethod internally.allowedRecursiveDelaySkippingboolean <optional>
stopAt-startAt Used as the "allowedRecursiveDelaySkipping" parameter when calling the
CB_AudioFileSprites#resumeAllmethod internally.onPlayStartfunction <optional>
Used as the "onPlayStart" parameter when calling the
CB_AudioFileSprites#resumeAllmethod internally.onStopfunction <optional>
Used as the "onStop" parameter when calling the
CB_AudioFileSprites#resumeAllmethod internally.audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#resumeAllmethod internally.spriteIdstring <optional>
'_WITHOUT_SPRITE_ASSOCIATED' Used as the "spriteId" when calling the
CB_AudioFileSprites#resumeAllmethod internally. Internal usage only recommended.Returns:
Returns an object whose property names will be the ID of each sprites group and their value will be the returning value of the internal call to the
CB_AudioFileSprites#resumeAllmethod.- Type
- Object
-
setAudioAPIAll(preferredAPIs [, callbackOk] [, callbackError] [, mandatory] [, forceReload] [, audioFiles]) → {integer}
-
Tries to change the audio API for all the existing
CB_AudioFileobjects or the desired ones (if provided). This method is not allowed to be called if a previous call to it did not finish yet. The function defined in the "callbackError" parameter, if any, will be called immediately if the method was previously called and it is still running currently. Uses theCB_AudioFileSprites#setAudioAPIAllmethod internally.Parameters:
Name Type Argument Default Description preferredAPIsarray | string Used as the "preferredAPIs" parameter when calling the
CB_AudioFileSprites#setAudioAPIAllmethod internally.callbackOkCB_AudioFileSpritesPool.setAudioAPIAll_CALLBACK_OK <optional>
Function that will be called when all the process was performed successfully, being "this" the
CB_AudioFileSpritesPoolobject.callbackErrorCB_AudioFileSpritesPool.setAudioAPIAll_CALLBACK_ERROR <optional>
Function that will be called when any error happened, being "this" the
CB_AudioFileSpritesPoolobject. This function will be called immediately if the method was previously called and it is still running currently.mandatoryboolean <optional>
false Used as the "mandatory" parameter when calling the
CB_AudioFileSprites#setAudioAPIAllmethod internally.forceReloadstring <optional>
false Used as the "forceReload" parameter when calling the
CB_AudioFileSprites#setAudioAPIAllmethod internally.audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#setAudioAPIAllmethod internally.Returns:
Returns the number of calls to the
CB_AudioFile#setAudioAPImethod that were performed.- Type
- integer
-
setVolumeAll( [volume] [, forceSetVolumeProperty] [, onSetVolume] [, audioFiles]) → {integer}
-
Sets the same volume for all the existing
CB_AudioFileobjects or the desired ones (if provided). Uses theCB_AudioFileSprites#setVolumeAllmethod internally.Parameters:
Name Type Argument Default Description volumenumber <optional>
CB_Speaker.getVolume()|CB_Configuration.CrossBase.CB_Speaker_DEFAULT_VOLUMEUsed as the "volume" parameter when calling the
CB_AudioFileSprites#setVolumeAllmethod internally.forceSetVolumePropertyboolean <optional>
false Used as the "forceSetVolumeProperty" parameter when calling the
CB_AudioFileSprites#setVolumeAllmethod internally.onSetVolumefunction <optional>
Used as the "onSetVolume" parameter when calling the
CB_AudioFileSprites#setVolumeAllmethod internally.audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#setVolumeAllmethod internally.Returns:
Returns the number of calls to the
CB_AudioFile#setVolumemethod that were performed internally.- Type
- integer
-
stopAll( [audioFiles]) → {integer}
-
Tries to stops all the existing
CB_AudioFileobjects or the desired ones (if provided), which are being played, by calling theirCB_AudioFile#stopmethod internally. Uses theCB_AudioFileSprites#stopAllmethod internally.Parameters:
Name Type Argument Default Description audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#stopAllmethod internally.Returns:
Returns the number of calls to the
CB_AudioFile#stopmethod that were performed.- Type
- integer
-
unmuteAll( [onUnmute] [, audioFiles]) → {integer}
-
Unmutes all the existing
CB_AudioFileobjects or the desired ones (if provided). Uses theCB_AudioFileSprites#unmuteAllmethod internally.Parameters:
Name Type Argument Default Description onUnmutefunction <optional>
Used as the "onUnmute" parameter when calling the
CB_AudioFileSprites#unmuteAllmethod internally.audioFilesarray <optional>
CB_AudioFileCache#audioFilesUsed as the "audioFiles" parameter when calling the
CB_AudioFileSprites#unmuteAllmethod internally.Returns:
Returns the number of calls to the
CB_AudioFile#unmutemethod that were performed.- Type
- integer
Type Definitions
-
DATA_OBJECT
-
Object with the desired data and options for the audio sprites. It is almost identical to the
CB_AudioFileSprites.DATA_OBJECTbut adding a "spritesGroups" property.Type:
- Object
- Source:
Properties:
Name Type Argument Default Description spritesGroupsCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECT <optional>
Object with the desired sprites groups, containing the
CB_AudioFileSprites.DATA_OBJECTobjects which will be used to create theCB_AudioFileSpritesobjects internally. Each group will have aCB_AudioFileSpritesobject. It will be used as the first parameter to call theCB_AudioFileSpritesPool#insertSpritesGroupsmethod internally. Some of the missing properties ("preferredAPIs", "preferredFormats", "minimumAudioFiles", "maximumAudioFiles", "minimumAudioFilesFree", "newAudioFilesWhenNeeded", "retries", "checkManually", "checkManuallyOnNeededCreated", "checkManuallyOnPlayingFailed", "checkManuallyOnCheckingFailed" and "disableAutoLoad") of theCB_AudioFileSprites.DATA_OBJECTobjects given will use the value set on the other properties of this object (if any).idstring <optional>
"" Desired identifier for the object. If a valid value is given, this will be added to the
CB_AudioFileSpritesPool#idproperty.preferredAPIsarray <optional>
CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APISArray of strings with the preferred audio API or audio APIs, in order of preference. Possible audio APIs are "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API). It will try to calculate and use the best one for the current client. If a valid value is given, this will be added to the
CB_AudioFileSpritesPool#preferredAPIsproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "preferredAPIs" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.preferredFormatsarray <optional>
CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_FORMATSArray of strings with the preferred audio format or audio formats (they can include just the format as 'audio/ogg' or also the codec as for example 'audio/ogg; codecs="vorbis"'), in order of preference. It will try to calculate and use the best one for the current client. If a valid value is given, this will be added to the
CB_AudioFileSpritesPool#preferredFormatsproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "preferredFormats" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.minimumAudioFilesinteger <optional>
CB_AudioFileCache.minimumAudioFiles_DEFAULTMinimum
CB_AudioFileobjects to create internally. It must be an integer being 1 the minimum. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#minimumAudioFilesproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "minimumAudioFiles" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.maximumAudioFilesinteger <optional>
CB_AudioFileCache.maximumAudioFiles_DEFAULTMaximum
CB_AudioFileobjects that are to be created internally. If it is set to null, there will not be a maximum (it will be unlimited). If an integer is provided, it must be the same number or greater than the value set in theCB_AudioFileCache#minimumAudioFilesproperty (also provided by the "minimumAudioFiles" of this object), allowing 1 minimum. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#maximumAudioFilesproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "maximumAudioFiles" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.minimumAudioFilesFreeinteger <optional>
parseInt( CB_AudioFileCache#minimumAudioFiles* 0.25 + 0.5)New
CB_AudioFileobjects will be created internally when the number of freeCB_AudioFileobjects reaches this limit. If provided, it must be an integer being 0 (zero) the minimum. It will end using a 25% of theCB_AudioFileSpritesPool#minimumAudioFilesby default, rounded to ceil, allowing 0 (zero) minimum. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#minimumAudioFilesFreeproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "minimumAudioFilesFree" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.newAudioFilesWhenNeededinteger <optional>
Math.min(parseInt( CB_AudioFileCache#minimumAudioFiles* 0.1 + 0.5), 1)Number of new
CB_AudioFileobjects to create internally when the minimum limit of freeCB_AudioFileobjects (CB_AudioFileSpritesPool#minimumAudioFilesFree) is reached. If provided, it must be an integer being 0 (zero) the minimum. It will end using a 10% of theCB_AudioFileSpritesPool#minimumAudioFilesby default, rounded to ceil, allowing 1 minimum. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#newAudioFilesWhenNeededproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "newAudioFilesWhenNeeded" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.retriesinteger <optional>
CB_AudioFileCache.retries_DEFAULTNumber of retries to try to load a
CB_AudioFileobject internally before trying to load the next possible one internally (if any). It must be an integer being 0 the minimum. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#retriesproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "retries" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.checkManuallyboolean <optional>
CB_AudioFileCache.checkManually_DEFAULTTells whether the
CB_AudioFileobjects must be checked automatically or not (manually) by default. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#checkManuallyproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "checkManually" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.checkManuallyOnNeededCreatedboolean <optional>
CB_AudioFileCache.checkManuallyOnNeededCreated_DEFAULTTells whether the
CB_AudioFileobjects must be checked automatically or not (manually) when creates a newCB_AudioFileobject needed. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#checkManuallyOnNeededCreatedproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "checkManuallyOnNeededCreated" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.checkManuallyOnPlayingFailedboolean <optional>
CB_AudioFileCache.checkManuallyOnPlayingFailed_DEFAULTTells whether the
CB_AudioFileobjects must be checked automatically or not (manually) when playing one has failed and tries to reload it. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#checkManuallyOnPlayingFailedproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "checkManuallyOnPlayingFailed" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.checkManuallyOnCheckingFailedboolean <optional>
CB_AudioFileCache.checkManuallyOnCheckingFailed_DEFAULTTells whether the
CB_AudioFileobjects must be checked automatically or not (manually) when checking one has failed and tries to reload it. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#checkManuallyOnCheckingFailedproperty. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "checkManuallyOnCheckingFailed" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally.onLoadfunction <optional>
Desired function to be called once the pool has been loaded. The first and unique parameter will be an integer with the
CB_AudioFileobjects that still need to be checked, if any, being "this" the currentCB_AudioFileSpritesPoolobject. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#onLoadproperty.onErrorfunction <optional>
Desired function to be called when any kind of error happens. The first and unique parameter will be a string with the error description (if it could be determined), being "this" the current
CB_AudioFileSpritesPoolobject. If a valid value is given, this will be added to theCB_AudioFileSpritesPool#onErrorproperty. If a function is set, it will always be called through theCB_AudioFileSpritesPool#errorFunctionmethod whenever the "onError" event of an internally-createdCB_AudioFileSpritesobject is fired.disableAutoLoadboolean <optional>
false If set to true, it will not create automatically the
CB_AudioFileobjects by calling theCB_AudioFileCache#createAudioFilesmethod internally. Internal usage only recommended. If theCB_AudioFileSprites.DATA_OBJECTobject (defined in theCB_AudioFileSpritesPool.SPRITES_GROUPS_OBJECTobject set in the "spritesGroups") of a certain sprites group does not contain the "disableAutoLoad" property, it will use the value of this property instead when creating itsCB_AudioFileSpritesobject internally. -
SPRITES_GROUPS_OBJECT
-
Object whose property names the identifiers of each sprite (a case-sensitive string) and their value is a
CB_AudioFileSprites.DATA_OBJECTobject.Type:
- Object
- Source:
Properties:
Name Type Description spritesGroupIdCB_AudioFileSprites.DATA_OBJECT Being the name of each property the unique identifier of a sprites group which will use a future internally-created
CB_AudioFileSpritesobject, the value will always be theCB_AudioFileSprites.DATA_OBJECTthat theCB_AudioFileSpritesobject will use to be created (received by its constructor). Some of the missing properties ("preferredAPIs", "preferredFormats", "minimumAudioFiles", "maximumAudioFiles", "minimumAudioFilesFree", "newAudioFilesWhenNeeded", "retries", "checkManually", "checkManuallyOnNeededCreated", "checkManuallyOnPlayingFailed", "checkManuallyOnCheckingFailed" and "disableAutoLoad") will use the value set on the properties of the mainCB_AudioFileSpritesPool.DATA_OBJECTobject (if any) used by theCB_AudioFileSpritesPoolobject. If a function in the "onError" parameter is given, it will always be wrapped so the main error function set on theCB_AudioFileSpritesPool#onErrorparameter will always be called (if any) through theCB_AudioFileSpritesPool#errorFunctionmethod.Example
{ "sprites_group_id_1" : CB_AudioFileSprites.DATA_OBJECT, "sprites_group_id_2" : CB_AudioFileSprites.DATA_OBJECT, "sprites_group_id_3" : CB_AudioFileSprites.DATA_OBJECT, ... } -
checkPlayingAll_CALLBACK_ERROR(errorsObject, performedActions, uncheckedObjects)
-
Callback function used by the
CB_AudioFileSpritesPool#checkPlayingAllmethod that will be called when not all was performed successfully.Parameters:
Name Type Description errorsObjectObject Object whose property names are the ID of each sprites group or "GENERAL_ERROR" if the error is not related to any sprites group and their value will be a
CB_AudioFileSpritesPool.checkPlayingAll_CALLBACK_ERROR_OBJECTobject.performedActionsinteger The number of
CB_AudioFileobjects that can be played).uncheckedObjectsinteger | undefined The number of
CB_AudioFileobjects that needed to be checked before calling this method (it will be undefined if it could not be determined). -
checkPlayingAll_CALLBACK_ERROR_OBJECT
-
An object with errors, used by the
CB_AudioFileSpritesPool.checkPlayingAll_CALLBACK_ERRORcallback (used by theCB_AudioFileSpritesPool#checkPlayingAllmethod).Type:
- Object
- Source:
Properties:
Name Type Description errorstring A string describing the error (if it was possible to be determined).
checkedinteger The number of
CB_AudioFileobjects that can be played.neededinteger | undefined The number of
CB_AudioFileobjects that needed to be checked before calling this method (it will be undefined if it could not be determined). -
checkPlayingAll_CALLBACK_OK(performedActions, uncheckedObjects)
-
Callback function used by the
CB_AudioFileSpritesPool#checkPlayingAllmethod that will be called when all the process was performed successfully.Parameters:
Name Type Description performedActionsinteger The number of
CB_AudioFileobjects that can be played.uncheckedObjectsinteger The number of
CB_AudioFileobjects that needed to be checked before calling this method. -
executeFunctionAll_ON_FINISH_CALLBACK(array, itemsAffected, delayMaximum)
-
Callback that is used when finishes all iterations after looping through the items. Being "this" an array with all the items.
Parameters:
Name Type Description arrayarray An array with all the items which were being looped.
itemsAffectedinteger The number of times that the "functionEach" callback was called (the most likely, matches the number of elements unless they are undefined or null).
delayMaximuminteger The maximum "delay" used.
-
getAudioFilesUsed_OBJECT
-
Object returned by the
CB_AudioFileSpritesPool#getAudioFilesUsedmethod. Each property names will be the the ID of each sprites group and their value will be aCB_AudioFileSprites.getAudioFilesUsed_OBJECTobject.Type:
- Object
- Source:
Properties:
Name Type Description spriteIdCB_AudioFileSpritesPool.getAudioFilesUsed_OBJECT Each property names will be the the ID of each sprites group and their value will be a
CB_AudioFileSprites.getAudioFilesUsed_OBJECTobject. -
setAudioAPIAll_CALLBACK_ERROR(errorsObject, errorsHappened, objectsChangedAPI, performedActions, actionsNeeded)
-
Callback function used by the
CB_AudioFileCache#setAudioAPIAllmethod that will be called when any error happened.Parameters:
Name Type Description errorsObjectObject Object whose property names are the ID of each sprites group or "GENERAL_ERROR" if the error is not related to any sprites group and their value will be a
CB_AudioFileSpritesPool.setAudioAPIAll_CALLBACK_ERROR_OBJECTobject each.errorsHappenedinteger The number of errors that happened, which could be greater than 1 if more than one internal call to the
CB_AudioFile#setAudioAPImethod failed.objectsChangedAPIinteger The number of
CB_AudioFileobjects that actually changed its audio API.performedActionsinteger The number of
CB_AudioFileobjects that ended with a desired audio API, including those ones which were already using it.actionsNeededinteger | undefined The total number of
CB_AudioFileobjects that were considered to perform the action (it will be undefined if it could not be determined). -
setAudioAPIAll_CALLBACK_ERROR_OBJECT
-
Object used by the
CB_AudioFileSpritesPool.setAudioAPIAll_CALLBACK_ERRORcallback. Unless it belongs to a general error, its information will only be regarding a certain sprites group.Type:
- Object
- Source:
Properties:
Name Type Description errorstring A string describing the error, if it was possible to be determined.
errorsinteger The number of errors that happened, which could be greater than 1 if more than one internal call to the
CB_AudioFile#setAudioAPImethod failed.changedinteger The number of objects that actually changed its audio API.
performedinteger The number of
CB_AudioFileobjects that ended with a desired audio API, including those ones which were already using it.neededinteger | undefined The total number of
CB_AudioFileobjects that were considered to perform the action (it will be undefined if it could not be determined). -
setAudioAPIAll_CALLBACK_OK(objectsChangedAPI, performedActions, actionsNeeded)
-
Callback function used by the
CB_AudioFileSpritesPool#setAudioAPIAllmethod that will be called when all the process was performed successfully.Parameters:
Name Type Description objectsChangedAPIinteger The number of
CB_AudioFileobjects that actually changed its audio API.performedActionsinteger The number of
CB_AudioFileobjects that ended with a desired audio API, including those ones which were already using it.actionsNeededinteger The total number of
CB_AudioFileobjects that were considered to perform the action (it will be undefined if it could not be determined).