I'm having some issues playing mp3 files using AudioClip with JavaFX.
my code is like this:
// define String path to mp3 file
myFilePath = "path/to/file.mp3";
// Create an AudioClip Object from path
audioToPlay = new AudioClip(Objects.requireNonNull(getClass().getResource(audioToPlay)).toExternalForm());
// play the AudioClip
audioToPlay.play();
The audio files I am playing are all mp3 files and they are all fairly short (< 5 seconds). About 80-90% of the files are playing without any issue but the rest aren't playing at all, or are only playing for a very short time (less than a second so it sounds like a click).
I have no idea why the 10-20% aren't working; they play perfectly fine using my media player and from my browser.
Is the issue because I'm using AudioClip? Should I be using something else to play my short audio files?
Edit: myFilePath is defined as a String and audioToPlay is defined as an AudioClip object.