I’m creating a simple media player using jlGUI and jAudiotagger libraries.
I’ve used a JSlider to implement an automatically moving indicator, as the playback progresses.
Now, I have to implement seeking the file by dragging, by registering that slider to generate events.
So the problem is, when register the seeker, the automatic seeking of the slider(while playing) also causes a ChangeEvent, so its seeking to its own position again and again.
How do I implement it?
How about creating a
ChangeListenerwhich lets you turn it on and off with a method call?So when you’re in animation mode it ignores the
stateChanged()events.When the user clicks on the
JSlider(recognize that with aMouseListener), stop the animation and callMyChangeListener.setAnimationMode(false)so that your listener will react to user interaction.