I have an Arraylist
path
containing paths to different .mp3 files. My current solution plays the clips as expected however plays them simultaneously. I wish for the media to complete it's play-through before reaching the end of the loop and increasing i
. I've had a Google and explored similar questions on here but none of the solutions seem to work as expected. See the current solution below:
public static void play(ArrayList path) {
for(int i = 0; i < path.size(); i++) {
String file = Main.gameDir + "/assets/sound/" + path.get(i) + ".mp3";
Media sound = new Media(new File(file).toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(sound);
mediaPlayer.play();
}
}
I have tried getting the status, but this always returns UNKNOWN
.
All and any help appreciated.