public abstract class SongPlayer
extends java.lang.Object
| Constructor and Description |
|---|
SongPlayer(Song song) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
createTickTask(long initialDelay)
Create the internal tick task.
|
float |
getCurrentTicksPerSecond() |
int |
getMillisecondPosition() |
Song |
getSong() |
int |
getTick() |
boolean |
isPaused() |
boolean |
isRunning() |
protected void |
onFinished()
Deprecated.
|
protected void |
onSongFinished()
Called when the song has finished playing.
|
protected void |
onTickException(java.lang.Throwable e)
Called when an exception occurs during playback.
|
protected abstract void |
playNotes(java.util.List<Note> notes)
Called each tick to play the notes for the current tick.
|
protected void |
postTick()
Called after each tick (Even when paused).
|
protected boolean |
preTick()
Deprecated.
|
protected void |
setCustomScheduler(java.util.concurrent.ScheduledExecutorService scheduler)
Disables the internal scheduler and uses the provided one instead.
|
void |
setMillisecondPosition(int milliseconds)
Sets the current playback position in milliseconds.
|
void |
setPaused(boolean paused)
Pauses or resumes the player.
|
protected void |
setSong(Song song)
Sets the song that should be played.
|
void |
setTick(int tick)
Sets the current tick.
|
protected boolean |
shouldTick()
Called before each tick (Even when paused).
|
void |
start()
Starts playing the song from the beginning.
|
void |
start(int delay)
Starts playing the song from the beginning.
|
void |
start(int delay,
int tick)
Starts playing the song from the given tick.
|
void |
stop()
Stops playing the song.
|
protected void |
tick()
Called every tick to play the notes.
|
public SongPlayer(Song song)
public void start()
public void start(int delay)
delay - The delay in milliseconds before starting the song.public void start(int delay,
int tick)
delay - The delay in milliseconds before starting the song.tick - The tick to start playing from.public void stop()
public boolean isRunning()
public Song getSong()
protected void setSong(Song song)
onSongFinished().song - The song to play.public float getCurrentTicksPerSecond()
public int getTick()
public void setTick(int tick)
tick - The tick to set.public int getMillisecondPosition()
public void setMillisecondPosition(int milliseconds)
milliseconds - The time to set the playback position to.public boolean isPaused()
public void setPaused(boolean paused)
paused - Whether the player should be paused.protected void setCustomScheduler(java.util.concurrent.ScheduledExecutorService scheduler)
scheduler - The scheduler to use for playing the song or null to disable builtin schedulingprotected void createTickTask(long initialDelay)
initialDelay - The initial delay in nanoseconds.protected void tick()
protected boolean shouldTick()
protected abstract void playNotes(java.util.List<Note> notes)
notes - The notes to play.protected void onSongFinished()
protected void postTick()
protected void onTickException(java.lang.Throwable e)
e - The exception that occurred.@Deprecated protected boolean preTick()
shouldTick()@Deprecated protected void onFinished()
onSongFinished()