I found a code on Stack Over Flow, I do not know if it works
I adapt it to my way
but there is always this file error not found like I explained in the Jtable Jprogressbar topic
Exception in thread "main" java.io.FileNotFoundException: 60s rock beat.wav (Le fichier spécifié est introuvable)
at java.base/java.io.FileInputStream.open0(Native Method)
1. tell us the "original" problem has been solved.
2. ask a new question stating your new problem.
This way it keeps the thread concentrated on a single concept.
In any case if you hear no sound, then as I stated in my previous answer you need to add a Thread.sleep(...) otherwise the JVM closes before the wav file can be played. You added your code in the wrong place.
To get the code working first do:
1. forget about the "sounds" folder. Put the .wav files in the same directory as the class file
2. the Thread.sleep(...) needs to be execute AFTER you start the music playing
That is try to solve one problem at a time to keep the logic simple. Once the above two steps work, then you worry about placing the .wav file in a separate folder.
The following example shows how to play 5 second of a song:
Once the above works you move the .wav files to your "sound" directory and then retest.
Give you variables meaningful names so you can understand how to use the variable. Why would you have a static variable and local variable both use the name "file"?
Are you sure you can have more than one clip open at a time? When I was playing around with it it wouldn't let me play another one while the resources ("line") was in use until I called clip.close() on the first one.
To answer a rob, yes it works with thread.sleep, was enough to move it
As the song lasts 16 seconds, I made thread.sleep (16000)
And to answer Corey, it's a bit of what I was looking for, a song after another, I just tested your code, it works perfectly well
if I understood correctly, must close the first song to go to the next
I will try to test it with the jprogressbar
What's the purpose of the HashMap? If you know the file name and the directory then what else do you need to look up? Is the value going to be an instance of a Track object for example? You already have a table in your GUI unless you've abandoned that for the time being.
The goal of hashmap is to have a collection with a key to its value
As it works by key, I thought to make a scanner associated with the key and playing music, it's just an idea
Is this feasible? I do not know
no i did not abandon my jtable
I am looking for ideas to operate each progress bar associated with the duration of the song