From 827be3bde828fcf8d7be949168ac4909f6c323a2 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Tue, 10 Nov 2009 13:23:00 +0100 Subject: [PATCH] Fix $if_mpd_playing and $mpd_percent when you stop playing a song, thanks Sakari Matikka --- src/mpd.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index a5680ad..2bfdf18 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -196,6 +196,20 @@ static void *update_mpd_thread(void *arg) } mpd_info.volume = status->volume; + if (status->random == 0) { + mpd_info.random = "Off"; + } else if (status->random == 1) { + mpd_info.random = "On"; + } else { + mpd_info.random = ""; + } + if (status->repeat == 0) { + mpd_info.repeat = "Off"; + } else if (status->repeat == 1) { + mpd_info.repeat = "On"; + } else { + mpd_info.repeat = ""; + } /* if (status->error) { printf("error: %s\n", status->error); } */ @@ -216,11 +230,7 @@ static void *update_mpd_thread(void *arg) break; } - if (status->state == MPD_STATUS_STATE_STOP) { - mpd_info.progress = (float) status->elapsedTime / - status->totalTime; - mpd_info.elapsed = status->elapsedTime; - } else if (status->state == MPD_STATUS_STATE_PLAY || + if (status->state == MPD_STATUS_STATE_PLAY || status->state == MPD_STATUS_STATE_PAUSE) { mpd_info.is_playing = 1; mpd_info.bitrate = status->bitRate; @@ -228,22 +238,10 @@ static void *update_mpd_thread(void *arg) status->totalTime; mpd_info.elapsed = status->elapsedTime; mpd_info.length = status->totalTime; - if (status->random == 0) { - mpd_info.random = "Off"; - } else if (status->random == 1) { - mpd_info.random = "On"; - } else { - mpd_info.random = ""; - } - if (status->repeat == 0) { - mpd_info.repeat = "Off"; - } else if (status->repeat == 1) { - mpd_info.repeat = "On"; - } else { - mpd_info.repeat = ""; - } } else { + mpd_info.progress = 0; mpd_info.is_playing = 0; + mpd_info.elapsed = 0; } if (conn->error) { -- 1.7.9.5