I have the following code, which creates a MediaPlayer
and plays an audio:
public void playSong(Songs song) {
this.media = new Media(getClass().getResource("/sounds/login_song.wav").toString());
this.soundPlayer = new MediaPlayer(media);
this.soundPlayer.setVolume(this.currentVolume);
this.soundPlayer.setAutoPlay(true);
this.soundPlayer.setCycleCount(MediaPlayer.INDEFINITE);
this.soundPlayer.play();
}
for creating an audio-loop I used:
this.soundPlayer.setAutoPlay(true);
this.soundPlayer.setCycleCount(MediaPlayer.INDEFINITE);
This works, when Iam starting my application from IDE. Iam using: Eclipse Oxygen.3a Release (4.7.3a).
When I export my application to a runnable JAR-file, the audio is only played once and doesnt loop. Running the Jar from terminal does not help, since no errors occur (java -jar MyApplication.jar).
Why are the audios not looping?