Play button now starts from selected song in playlist.

This commit is contained in:
neviyn 2016-02-24 15:59:23 +00:00
parent c2920ddb47
commit 427c648e33
2 changed files with 8 additions and 1 deletions

View File

@ -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();

View File

@ -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();
}
}