public class Music
extends java.lang.Object
A Music track is a piece of music that can be played in the background of a CellGame. Because a CellGame must ensure that it is never playing more than one Music track at a time, all playing, looping, stopping, pausing, and fading of Music tracks is controlled by methods of the CellGame.
Like Sprites, SpriteSheets, and Sounds, Music tracks can be manually loaded and unloaded into and out of memory. Loading may take a moment, but while a Music track is not loaded, it cannot play.
Modifier and Type | Field and Description |
---|---|
static Music |
BLANK
A blank Music track that produces no sound and plays indefinitely.
|
Constructor and Description |
---|
Music(java.lang.String path,
boolean load)
Creates a new Music track from an audio file.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isLoaded()
Returns whether this Music track is loaded.
|
boolean |
load()
Loads this Music track if it is not already loaded.
|
boolean |
unload()
Unloads this Music track if it is currently loaded.
|
public static final Music BLANK
public Music(java.lang.String path, boolean load)
path
- The relative path to the audio fileload
- Whether this Music track should load upon creationpublic final boolean isLoaded()
public final boolean load()
public final boolean unload()