-
- All Known Implementing Classes:
AndroidAudioService
,DummyAudioService
public interface AudioService
The audio service provides access to loading native audio (sound and music) objects.Example
AudioService.create().ifPresent(service -> { service.loadSound(getClass().getResource("test.wav")) .ifPresent(audio -> audio.play()); });
Android Configuration: none
iOS Configuration: none
- Since:
- 4.0.9
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static java.util.Optional<AudioService>
create()
java.util.Optional<Audio>
loadMusic(java.net.URL url)
Load a (long) music object (typically ".mp3") from a given URL.java.util.Optional<Audio>
loadSound(java.net.URL url)
Load a (short) sound object (typically ".wav") from a given URL.
-
-
-
Method Detail
-
create
static java.util.Optional<AudioService> create()
- Returns:
- an instance of
AudioService
.
-
loadSound
java.util.Optional<Audio> loadSound(java.net.URL url)
Load a (short) sound object (typically ".wav") from a given URL. This call will block until the audio is fully loaded. You may wish to load the audio on a non-JavaFX thread.- Parameters:
url
- where the sound file is- Returns:
- optional containing the sound file or empty if any errors occurred during loading
-
loadMusic
java.util.Optional<Audio> loadMusic(java.net.URL url)
Load a (long) music object (typically ".mp3") from a given URL. This call will block until the audio is fully loaded. You may wish to load the audio on a non-JavaFX thread.- Parameters:
url
- where the music file is- Returns:
- optional containing the music file or empty if any errors occurred during loading
-
-