Class Jukebox
java.lang.Object
de.pirckheimer_gymnasium.engine_pi.sound.Jukebox
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreatePlayback(Sound sound, boolean loop) Creates anSoundPlaybackobject that can be configured prior to starting.createPlayback(String filePath, boolean loop) Liefert eine Liste mit allen Musikwiedergaben.intGets the maximum distance from the listener at which a sound source can still be heard.getMusic()Gets the "main" music that is playing.Sets the currently playing track to aLoopedTrackwith the specified musicSound.Sets the currently playing track to the specified track.Sets the currently playing track to the specified track.Plays the specified track.playMusic(Track track, Consumer<? super MusicPlayback> config, boolean restart, boolean stop) Plays the specified track, optionally configuring it before starting.voidsetMaxDistance(int radius) Sets the default maximum distance from the listener at which a sound source can still be heard.voidStoppt die Wiedergabe der aktuellen Hintergrundmusik.
-
Field Details
-
DEFAULT_MAX_DISTANCE
public static final int DEFAULT_MAX_DISTANCE- See Also:
-
-
Constructor Details
-
Jukebox
public Jukebox()
-
-
Method Details
-
getMaxDistance
public int getMaxDistance()Gets the maximum distance from the listener at which a sound source can still be heard.- Returns:
- The maximum distance at which a sound can be heard.
-
playMusic
Sets the currently playing track to aLoopedTrackwith the specified musicSound. This has no effect if the specified track is already playing.- Parameters:
music- TheSoundto be played.- Returns:
- The playback of the music
-
playMusic
Sets the currently playing track to the specified track. This has no effect if the specified track is already playing.- Parameters:
track- The track to play- Returns:
- The playback of the music
-
playMusic
Sets the currently playing track to the specified track.- Parameters:
track- The track to playrestart- Whether to restart if the specified track is already playing, determined byObject.equals(Object)- Returns:
- The playback of the music
-
playMusic
Plays the specified track.- Parameters:
track- The track to playrestart- Whether to restart if the specified track is already playing, determined byObject.equals(Object)stop- Whether to stop an existing track if present- Returns:
- The playback of the music
-
playMusic
public MusicPlayback playMusic(Track track, Consumer<? super MusicPlayback> config, boolean restart, boolean stop) Plays the specified track, optionally configuring it before starting.- Parameters:
track- The track to playconfig- A call to configure the playback prior to starting, which can benullrestart- Whether to restart if the specified track is already playing, determined byObject.equals(Object)stop- Whether to stop an existing track if present- Returns:
- The playback of the music
-
getMusic
Gets the "main" music that is playing. This usually means the last call toplayMusic, though if the music has been stopped it will benull.- Returns:
- The main music, which could be
null.
-
getAllMusic
Liefert eine Liste mit allen Musikwiedergaben.- Returns:
- Eine Liste mit allen Musikwiedergaben.
-
setMaxDistance
public void setMaxDistance(int radius) Sets the default maximum distance from the listener at which a sound source can still be heard. If the distance between the sound source and the listener is greater than the specified value, the volume is set to 0.- Parameters:
radius- The maximum distance at which sounds can still be heard.
-
stopMusic
public void stopMusic()Stoppt die Wiedergabe der aktuellen Hintergrundmusik. -
getSound
-
createPlayback
Creates anSoundPlaybackobject that can be configured prior to starting.Unlike the
playSoundmethods, theSoundPlaybackobjects returned by this method must be started using thePlayback.start()method. However, necessary resources are acquired immediately upon calling this method, and will remain in use until the playback is either cancelled or finalized.- Parameters:
sound- The sound to playloop- Whether to loop the sound- Returns:
- An
SoundPlaybackobject that can be configured prior to starting, but will need to be manually started.
-
createPlayback
-
playSound
-
playSound
-
playSound
-