Welcome! Log In Create A New Profile

Advanced

LCD4Linux MPD Date/Track/Disc patch

Posted by tsunulukai 
LCD4Linux MPD Date/Track/Disc patch
August 08, 2014 05:29PM
Hi folks,

I've been playing a little with LCD4Linux and MPD and was disappointed to see the date, track number or disc of a song couldn't be extracted with the last official revision of the plugin.

I've patched it to add this possibility.

Here's the diff for anyone wishing to add this functionnality too:
--- plugin_mpd.c        2011-07-27 02:53:04.000000000 +0000
+++ plugin_mpd.c        2014-08-08 22:09:44.029630371 +0000
@@ -1,5 +1,5 @@
-/* $Id$
- * $URL$
+/* $Id: plugin_mpd.c 1150 2011-07-27 02:53:04Z michael $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/plugin_mpd.c $
  *
  * mpd informations v0.82
  *
@@ -67,6 +67,12 @@
  * changelog v0.83 (26.07.2008):
  *  added:    -mpd::cmd* commands
  *
+ *
+ * changelog v0.83b (09.08.2014) - Tsuñulukaï patch:
+ *  added:    -mpd::disc   - song disc number
+ *            -mpd::track  - song track number
+ *            -mpd::date   - song year
+ *
  */

 /*
@@ -576,6 +582,45 @@
        SetResult(&result, R_STRING, "");
 }

+static void getTrack(RESULT * result)
+{
+    const char *value = NULL;
+    mpd_update();
+    if (currentSong != NULL) {
+       value = mpd_song_get_tag(currentSong, MPD_TAG_TRACK, 0);
+    }
+    if (value)
+       SetResult(&result, R_STRING, charset_from_utf8(value));
+    else
+       SetResult(&result, R_STRING, "");
+}
+
+static void getDisc(RESULT * result)
+{
+    const char *value = NULL;
+    mpd_update();
+    if (currentSong != NULL) {
+       value = mpd_song_get_tag(currentSong, MPD_TAG_DISC, 0);
+    }
+    if (value)
+       SetResult(&result, R_STRING, charset_from_utf8(value));
+    else
+       SetResult(&result, R_STRING, "");
+}
+
+static void getDate(RESULT * result)
+{
+    const char *value = NULL;
+    mpd_update();
+    if (currentSong != NULL) {
+       value = mpd_song_get_tag(currentSong, MPD_TAG_DATE, 0);
+    }
+    if (value)
+       SetResult(&result, R_STRING, charset_from_utf8(value));
+    else
+       SetResult(&result, R_STRING, "");
+}
+
 static void getFilename(RESULT * result)
 {
     const char *value = NULL;
@@ -881,6 +926,9 @@
     AddFunction("mpd::artist", 0, getArtist);
     AddFunction("mpd::title", 0, getTitle);
     AddFunction("mpd::album", 0, getAlbum);
+    AddFunction("mpd::track", 0, getTrack);
+    AddFunction("mpd::disc", 0, getDisc);
+    AddFunction("mpd::date", 0, getDate);
     AddFunction("mpd::file", 0, getFilename);
     AddFunction("mpd::totalTimeSec", 0, totalTimeSec);
     AddFunction("mpd::elapsedTimeSec", 0, elapsedTimeSec);

You'll also find attached screen captures for a 320x240 LCD screen and the lcd4linux.conf used to generate them.

Greetz



Edited 3 time(s). Last edit at 08/08/2014 06:11PM by tsunulukai.
Attachments:
open | download - lcd4linux.conf (21.9 KB)
open | download - lcd4linux-mpd-big.png (2.2 KB)
open | download - lcd4linux-mpd-small.png (5.7 KB)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: