Play button now starts from selected song in playlist.
This commit is contained in:
parent
c2920ddb47
commit
427c648e33
@ -66,7 +66,10 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
||||
//Action Listeners
|
||||
playButton.addActionListener(e -> {
|
||||
if (playList.getRowCount() > 0) {
|
||||
player.playSong(playlistTableModel.getFirst());
|
||||
if(playList.getSelectedRowCount() > 0)
|
||||
player.playSong(playlistTableModel.getSong(playList.getSelectedRow()));
|
||||
else
|
||||
player.playSong(playlistTableModel.getFirst());
|
||||
}
|
||||
});
|
||||
MouseListener mouseListener = new libraryMouseAdapter();
|
||||
|
@ -99,4 +99,8 @@ public class PlaylistTableModel extends AbstractTableModel {
|
||||
songList.remove(song);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public Optional<Song> getSong(int index){
|
||||
return songList.size() > 0 && index >= 0 && index < songList.size() ? Optional.of(songList.get(index)) : Optional.empty();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user