public class MusicManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private AudioFileLoader |
audioFileLoader
The
AudioFileLoader for loading audio files. |
private DebugWriter |
debugSound
The writer for logging sound related information or
null to not
log. |
private boolean |
enabled
Whether background music is enabled.
|
private boolean |
muted
Whether background music is muted.
|
private java.lang.String |
name
The currently playing music name.
|
private Processor |
processor
The currently running processor, or
null if none is active or if
music is disabled. |
private java.lang.Thread |
thread
The
Thread executing processor . |
Constructor and Description |
---|
MusicManager(AudioFileLoader audioFileLoader,
DebugWriter debugSound)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
play(java.lang.String name)
Plays the given music.
|
private void |
restart()
Restarts the current music.
|
void |
setEnabled(boolean enabled)
Sets whether background music is enabled.
|
void |
setMuted(boolean muted)
Sets whether background music is muted.
|
void |
shutdown()
Terminates a playing background music and free resources.
|
@NotNull private final AudioFileLoader audioFileLoader
AudioFileLoader
for loading audio files.@Nullable private final DebugWriter debugSound
null
to not
log.private boolean enabled
private boolean muted
@Nullable private java.lang.String name
null
if no music is
playing.@Nullable private Processor processor
null
if none is active or if
music is disabled.@Nullable private java.lang.Thread thread
public MusicManager(@NotNull AudioFileLoader audioFileLoader, @Nullable DebugWriter debugSound)
audioFileLoader
- the audio file loader for loading audio filesdebugSound
- the writer for logging sound related information or
null
to not logpublic void play(@Nullable java.lang.String name)
name
- the music name, or null
to stop playing musicprivate void restart()
public void setEnabled(boolean enabled)
enabled
- whether background music is enabledpublic void setMuted(boolean muted)
muted
- whether background music is mutedpublic void shutdown()