JSlider for music player
Hello,
I am implementing a player in Java for wave files. I have stop, pause, play, button etc.
In addition, I have a JSlider that I would want to indicate the location in the song is played.
Something like this obviously needs like a constant event that will trigger the update.
I tried writing:
for(int i=jSlider.getMinimum(); i<=jSlider.getMaximum;){
int val = calc_point_for_slider(song, jSlider);
jSlider.setValue(val);
Thread.sleep(1000);
But it just "jams" the computer for the duration of the for-loop and only after the last iteration, the slider's button "jumps" from the begining to the start (without slowly progressing).
}
If you could help me, I'd be very greatful.
Thank you.
|