playingRow now reacts to changes in playlist. Fixed song highlighting not working when stopping playback.

This commit is contained in:
neviyn 2016-03-11 16:41:57 +00:00
parent daedca9bf6
commit b0c1dd10bc
2 changed files with 10 additions and 2 deletions

View File

@ -158,6 +158,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
@Override @Override
public void setSongHighlighting(Song playingSong) { public void setSongHighlighting(Song playingSong) {
int index = playlistTableModel.getSongIndex(playingSong); int index = playlistTableModel.getSongIndex(playingSong);
if(index >= 0)
SwingUtilities.invokeLater(() -> playList.setRowSelectionInterval(index, index)); SwingUtilities.invokeLater(() -> playList.setRowSelectionInterval(index, index));
playlistTableModel.setPlayingRow(index); playlistTableModel.setPlayingRow(index);
} }
@ -201,7 +202,10 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
playlistTableModel.removeSong(invalidSong); playlistTableModel.removeSong(invalidSong);
} }
public void playerStopped(){ playlistTableModel.setPlayingRow(-1); } public void playerStopped(){
setSongHighlighting(player.getCurrentSong());
playlistTableModel.setPlayingRow(-1);
}
/** /**
* Refresh the library with songs in the currently selected display format. * Refresh the library with songs in the currently selected display format.

View File

@ -114,6 +114,10 @@ public class PlaylistTableModel extends AbstractTableModel {
if(songList.size() > index && index >= 0){ if(songList.size() > index && index >= 0){
songList.remove(index); songList.remove(index);
fireTableRowsDeleted(index, index); fireTableRowsDeleted(index, index);
if(index < playingRow)
playingRow--;
else if(playingRow == index)
playingRow = -1;
} }
} }