fixed mpd nullpointer exceptions

This commit is contained in:
Lucas Pleß 2012-06-28 20:12:36 +02:00
parent f106675753
commit 8acace8c19
1 changed files with 12 additions and 6 deletions

View File

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