fixed: don't disconnect if mpd doesn't send artist or title info

This commit is contained in:
Bob van Loosen 2012-12-23 19:41:40 +01:00
parent b74fc88fb7
commit 8234535ffb

View file

@ -93,19 +93,25 @@ bool CMpdClient::GetCurrentSong()
if (datastream.fail()) if (datastream.fail())
break; break;
string tmpline = line;
string word; string word;
if (GetWord(line, word)) if (GetWord(tmpline, word))
{ {
if (word == "Artist:") if (word == "Artist:")
artist = line.substr(1); artist = tmpline.substr(1);
else if (word == "Title:") else if (word == "Title:")
title = line.substr(1); title = tmpline.substr(1);
} }
if (!artist.empty() && !title.empty()) if (line == "OK")
{ {
string song = artist + " - " + title; if (artist.empty())
SetCurrentSong(song); artist = "Unknown artist";
if (title.empty())
title = "Unknown title";
SetCurrentSong(artist + " - " + title);
return true; return true;
} }
} }