diff --git a/src/de/ctdo/crashtest/mpd/MPDController.java b/src/de/ctdo/crashtest/mpd/MPDController.java index 42728fc..614e2ee 100644 --- a/src/de/ctdo/crashtest/mpd/MPDController.java +++ b/src/de/ctdo/crashtest/mpd/MPDController.java @@ -48,7 +48,7 @@ public class MPDController implements IMPDController { @Override public void run() { synchronized (mpd) { - addToPlayListIfNeeded(artist, title); + doPlaySong(artist,title); } @@ -68,6 +68,8 @@ public class MPDController implements IMPDController { int tries = 3; while(tries>0) { + addToPlayListIfNeeded(artist, title); + for(MPDSong song: playlist.getSongList()) { if(checkSong(song, artist, title)) { System.out.println("MPD: stopping, playing, go..."); @@ -85,7 +87,7 @@ public class MPDController implements IMPDController { System.out.println("MPD: song is correctly playing"); return; } else { - System.out.println("MPD: wrong track is playing. " + song.getArtist() + " - " + song.getTitle()); + System.out.println("MPD: wrong track is playing"); } System.out.println("MPD: next try"); @@ -102,10 +104,14 @@ public class MPDController implements IMPDController { } private boolean checkSong(final MPDSong song, final String artist, final String title) { - if(song.getArtist() != null && song.getTitle() != null) { - if(song.getArtist().getName().toLowerCase().contentEquals(artist.toLowerCase()) && - song.getTitle().toLowerCase().contentEquals(title.toLowerCase())) { - return true; + if(song != null) { + if(song.getArtist() != null && song.getTitle() != null) { + if(song.getArtist().getName().toLowerCase().contentEquals(artist.toLowerCase()) && + song.getTitle().toLowerCase().contentEquals(title.toLowerCase())) { + return true; + } + } else { + System.out.println("MPD: song is nullb"); } } else { System.out.println("MPD: track title or artist is null " + artist + " - " + title);