Hi,
I am making a song player in java with playlist functionality. I got my mp3 songs running all right. What i basically do in my player is search a folder for mp3 files and then add all to the playlist. Till here, it's fine and doing good. But the problem is that i don't know how to use timer classes of java to schedule next song's playing in java after first's stop. I am using jTable to store song details and on click of the row on table song starts playing but after that since i am not able to code in timer, program does not play next song.
I need help with scheduling timers, provided length of current song is known to me.
Below is the code:
Custom Player- My player class.
mouse clicked action is on jTable1
` MouseListener ml=new MouseListener(){
CustomPlayer p=new CustomPlayer();
public void mouseClicked(MouseEvent e) {
int column=jTable1.getSelectedColumn();
final int row=jTable1.getSelectedRow();
if(jTable1.getValueAt(row, column)!=null && column==0){
System.out.println(jTable1.getValueAt(row, column));
if(p.isRunning)p.close();
p.setPath((String) jTable1.getValueAt(row, 6));
Timer t=new Timer();
p.play(-1);
}
}
public void mousePressed(MouseEvent e) {
}public void mouseReleased(MouseEvent e) {
}public void mouseEntered(MouseEvent e) {
}public void mouseExited(MouseEvent e) {
}
};
jTable1.addMouseListener(ml);
}`
I hope i am clear. Thanks.