summaryrefslogtreecommitdiff
path: root/watrack_mpd/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'watrack_mpd/main.c')
-rwxr-xr-xwatrack_mpd/main.c90
1 files changed, 77 insertions, 13 deletions
diff --git a/watrack_mpd/main.c b/watrack_mpd/main.c
index a64265e..b7ceb14 100755
--- a/watrack_mpd/main.c
+++ b/watrack_mpd/main.c
@@ -74,7 +74,7 @@ LPINFOPROC GetPlayerInfo(LPSONGINFO info, int flags)
return 0;
}
Parser();
-/* info->album = SongInfo.album;
+/*
info->channels = SongInfo.channels;
info->codec = SongInfo.codec;
@@ -103,10 +103,12 @@ LPINFOPROC GetPlayerInfo(LPSONGINFO info, int flags)
info->title = SongInfo.title;
info->artist = SongInfo.artist;
info->genre = SongInfo.genre;
+ info->album = SongInfo.album;
+ info->year = SongInfo.year;
/* info->url = SongInfo.url; //??
info->vbr = SongInfo.vbr;
info->volume = SongInfo.volume;
- info->year = SongInfo.year;*/
+ */
return 0;
}
LPCOMMANDPROC SendCommand(HWND wnd, int command, int value)
@@ -147,7 +149,10 @@ int Parser()
static char ver[16];
nlpr.cbSize = sizeof(nlpr);
nlpr.dwTimeout = 5;
-
+ if(!ghConnection)
+ {
+ Start();
+ }
if(ghConnection)
{
int recvResult;
@@ -184,10 +189,8 @@ int Parser()
strcpy(ver, tmp);
SongInfo.txtver = (TCHAR*)mir_a2t(tmp);
}
- else if(strlen(ver) > 2)
- SongInfo.txtver = (TCHAR*)mir_a2t(tmp);
- else if (!SongInfo.txtver)
- SongInfo.txtver = _T("");
+ else
+ SongInfo.txtver = (TCHAR*)mir_a2t(ver);
if(ptr = strstr(buf, "file:"))
{
ptr = &ptr[6];
@@ -197,7 +200,7 @@ int Parser()
SongInfo.mfile = (TCHAR*)mir_a2t(tmp);
}
- else if(!SongInfo.mfile)
+ else
SongInfo.mfile = _T("");
if(ptr = strstr(buf, "Time:"))
{
@@ -214,7 +217,7 @@ int Parser()
ptr = &ptr[6];
for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
tmp[i] = ptr[i];
- tmp[i+1] = '\0';
+ tmp[i] = '\0';
SongInfo.time = atoi(tmp);
}
else if(!SongInfo.time)
@@ -227,7 +230,7 @@ int Parser()
tmp[i] = '\0';
SongInfo.title = (TCHAR*)mir_a2t(tmp);
}
- else if(!SongInfo.title)
+ else
SongInfo.title = _T("");
if(ptr = strstr(buf, "Artist:"))
{
@@ -237,7 +240,7 @@ int Parser()
tmp[i] = '\0';
SongInfo.artist = (TCHAR*)mir_a2t(tmp);
}
- else if(!SongInfo.artist)
+ else
SongInfo.artist = _T("");
if(ptr = strstr(buf, "Genre:"))
{
@@ -247,14 +250,75 @@ int Parser()
tmp[i] = '\0';
SongInfo.genre = (TCHAR*)mir_a2t(tmp);
}
- else if(!SongInfo.genre)
+ else
SongInfo.genre = _T("");
+ if(ptr = strstr(buf, "Album:"))
+ {
+ ptr = &ptr[7];
+ for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
+ tmp[i] = ptr[i];
+ tmp[i] = '\0';
+ SongInfo.album = (TCHAR*)mir_a2t(tmp);
+ }
+ else
+ SongInfo.album = _T("");
+ if(ptr = strstr(buf, "Date:"))
+ {
+ ptr = &ptr[6];
+ for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
+ tmp[i] = ptr[i];
+ tmp[i] = '\0';
+ SongInfo.year = (TCHAR*)mir_a2t(tmp);
+ }
+ else
+ SongInfo.year = _T("");
+ if(ptr = strstr(buf, "volume:"))
+ {
+ ptr = &ptr[8];
+ for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
+ tmp[i] = ptr[i];
+ tmp[i] = '\0';
+ SongInfo.volume = atoi(tmp);
+ }
+ else if(!SongInfo.volume)
+ SongInfo.volume = 0;
+ if(ptr = strstr(buf, "audio:"))
+ {
+ ptr = &ptr[7];
+ for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
+ tmp[i] = ptr[i];
+ tmp[i] = '\0';
+ SongInfo.khz = atoi(tmp);
+ }
+ else if(!SongInfo.khz)
+ SongInfo.khz = 0;
+ if(ptr = strstr(buf, "bitrate:"))
+ {
+ ptr = &ptr[9];
+ for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
+ tmp[i] = ptr[i];
+ tmp[i] = '\0';
+ SongInfo.kbps = atoi(tmp);
+ }
+ else if(!SongInfo.kbps)
+ SongInfo.kbps = 0;
+
+ if(ptr = strstr(buf, "Track:"))
+ {
+ ptr = &ptr[7];
+ for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
+ tmp[i] = ptr[i];
+ tmp[i] = '\0';
+ SongInfo.track = atoi(tmp);
+ }
+ else if(!SongInfo.track)
+ SongInfo.track = 0;
if(ptr = strstr(buf, "state:"))
{
ptr = &ptr[7];
for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++)
tmp[i] = ptr[i];
- tmp[i+1] = '\0';
+ tmp[i] = '\0';
if(strstr(tmp, "play"))
gbState = WAT_MES_PLAYING;
if(strstr(tmp, "pause"))