Skip to main content

FlixelSoundSource

View source

class

org.flixelgdx.audio.FlixelSoundSource

public final class FlixelSoundSource

Cached sound "source" (asset) that can spawn fresh FlixelSound instances on demand.

Do not cache FlixelSound playback objects directly: a playback object has mutable state (volume/pan/time/playing) and cannot be safely shared across callers or overlapping plays.

Constructors

FlixelSoundSource(String)

public FlixelSoundSource(String assetKey)

Creates a sound source with the given asset key.

Parameters:

NameDescription
assetKeyThe path or key identifying the audio asset.

FlixelSoundSource(String, boolean)

public FlixelSoundSource(String assetKey, boolean external)

Creates a sound source with the given asset key and external flag.

Parameters:

NameDescription
assetKeyThe path or key identifying the audio asset.
externaltrue if the path is an absolute external path.

Methods

getAssetKey()

public String getAssetKey()

Returns the asset key (path) for this sound source.

Returns: The asset key; never null.


isExternal()

public boolean isExternal()

Returns whether this source uses an external (absolute) path.

Returns: true if external.


getExternal()

public boolean getExternal()

Returns whether this source uses an external (absolute) path.


create(Object)

public FlixelSound create(Object group)

Creates a new playable FlixelSound instance using the provided group (or the default SFX group if null).

Parameters:

NameDescription
groupGroup handle from the backend factory, or null.

Returns: A new sound instance.


create()

public FlixelSound create()

Convenience overload using the default SFX group.

Returns: A new sound instance.


fromFile(FileHandle)

public static FlixelSoundSource fromFile(FileHandle handle)

Convenience constructor from a libGDX file handle (uses handle.path() as key).

Parameters:

NameDescription
handleThe file handle to the audio file.

Returns: A new sound source.