Package edu.cornell.gdiac.assets
Class SoundLoader
java.lang.Object
com.badlogic.gdx.assets.loaders.AssetLoader<T,P>
com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<com.badlogic.gdx.audio.Sound,SoundLoader.SoundParameters>
edu.cornell.gdiac.assets.SoundLoader
public class SoundLoader
extends com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<com.badlogic.gdx.audio.Sound,SoundLoader.SoundParameters>
This class is an
AssetLoader
to load Sound
assets.
Given the primitive state of LibGDX audio, we cannot do much more than
specify the filename when loading the asset. If you want more flexibility,
you must use the SoundEffect
class instead.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The definable parameters for aSound
object. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.badlogic.gdx.assets.loaders.FileHandleResolver
A reference to the file handle resolver (inaccessible in parent class) -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new SoundBufferLoader with an internal file resolverSoundLoader
(com.badlogic.gdx.assets.loaders.FileHandleResolver resolver) Creates a new SoundBufferLoader with the given file resolver -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.utils.Array<com.badlogic.gdx.assets.AssetDescriptor>
getDependencies
(String fileName, com.badlogic.gdx.files.FileHandle file, SoundLoader.SoundParameters params) Returns the other assets this asset requires to be loaded first.protected com.badlogic.gdx.audio.Sound
Returns theSound
instance currently loaded by this loader.void
loadAsync
(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, SoundLoader.SoundParameters params) Loads the thread-safe part of the asset and injects any dependencies into the AssetManager.com.badlogic.gdx.audio.Sound
loadSync
(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, SoundLoader.SoundParameters params) Loads the main thread part of the asset.Methods inherited from class com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader
unloadAsync
Methods inherited from class com.badlogic.gdx.assets.loaders.AssetLoader
resolve
-
Field Details
-
resolver
protected com.badlogic.gdx.assets.loaders.FileHandleResolver resolverA reference to the file handle resolver (inaccessible in parent class)
-
-
Constructor Details
-
SoundLoader
public SoundLoader()Creates a new SoundBufferLoader with an internal file resolver -
SoundLoader
public SoundLoader(com.badlogic.gdx.assets.loaders.FileHandleResolver resolver) Creates a new SoundBufferLoader with the given file resolver- Parameters:
resolver
- The file resolver
-
-
Method Details
-
getLoadedSound
protected com.badlogic.gdx.audio.Sound getLoadedSound()Returns theSound
instance currently loaded by this loader.If nothing has been loaded, this returns
null
.- Returns:
- the
Sound
instance currently loaded by this loader.
-
loadAsync
public void loadAsync(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, SoundLoader.SoundParameters params) Loads the thread-safe part of the asset and injects any dependencies into the AssetManager.This is used to load non-OpenGL parts of the asset that do not require the context of the main thread. As audio is thread-safe, this method does all of the work.
- Specified by:
loadAsync
in classcom.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<com.badlogic.gdx.audio.Sound,
SoundLoader.SoundParameters> - Parameters:
manager
- The asset managerfileName
- The name of the asset to loadfile
- The resolved file to loadparams
- The parameters to use for loading the asset
-
loadSync
public com.badlogic.gdx.audio.Sound loadSync(com.badlogic.gdx.assets.AssetManager manager, String fileName, com.badlogic.gdx.files.FileHandle file, SoundLoader.SoundParameters params) Loads the main thread part of the asset.This is used to load OpenGL parts of the asset that require the context of the main thread.
- Specified by:
loadSync
in classcom.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<com.badlogic.gdx.audio.Sound,
SoundLoader.SoundParameters> - Parameters:
manager
- The asset managerfileName
- The name of the asset to loadfile
- The resolved file to loadparams
- The parameters to use for loading the asset
-
getDependencies
public com.badlogic.gdx.utils.Array<com.badlogic.gdx.assets.AssetDescriptor> getDependencies(String fileName, com.badlogic.gdx.files.FileHandle file, SoundLoader.SoundParameters params) Returns the other assets this asset requires to be loaded first.This method may be called on a thread other than the GL thread. It may return null if there are no dependencies.
- Specified by:
getDependencies
in classcom.badlogic.gdx.assets.loaders.AssetLoader<com.badlogic.gdx.audio.Sound,
SoundLoader.SoundParameters> - Parameters:
fileName
- The name of the asset to loadfile
- The resolved file to loadparams
- parameters for loading the asset- Returns:
- the other assets this asset requires to be loaded first.
-