Re: [Rhythmbox-devel] DACP (iTunes remote) support added
- From: Peter <rhythmbox-devel maubp freeserve co uk>
- To: Alexandre Rosenfeld <alexandre rosenfeld gmail com>
- Cc: rhythmbox-devel gnome org
- Subject: Re: [Rhythmbox-devel] DACP (iTunes remote) support added
- Date: Sun, 24 Oct 2010 01:50:59 +0100
On Sun, Oct 24, 2010 at 1:15 AM, Peter wrote:
> However, if the cover art is an image file on disc (JPG, PNG,
> etc) then RB can just give the filename to libdmapsharing and
> it will shrink it (if needed) and turn it into PNG (if needed).
> I've tried this by making rb_dacp_player_now_playing_artwork
> return different hard coded filenames, and it works :)
>
> I haven't quite managed to get the the entry metadata
> RHYTHMDB_PROP_COVER_ART_URI from RB yet...
> but this should be enough to support the DCAP request
> /ctrl-int/1/nowplayingartwork.
Got it to work, RB DAAP/DCAP plugin patch attached to
enable support for the now playing artwork. Comments
please.
Peter
diff --git a/plugins/daap/rb-dacp-player.c b/plugins/daap/rb-dacp-player.c
index f5d4875..ca4f84a 100644
--- a/plugins/daap/rb-dacp-player.c
+++ b/plugins/daap/rb-dacp-player.c
@@ -47,6 +47,7 @@
struct _RBDACPPlayerPrivate {
RBShell *shell;
RBShellPlayer *shell_player;
+ RhythmDB *rdb;
};
static void rb_dacp_player_get_property (GObject *object, guint prop_id,
@@ -119,6 +120,7 @@ rb_dacp_player_finalize (GObject *object)
g_object_unref (player->priv->shell);
g_object_unref (player->priv->shell_player);
+ g_object_unref (player->priv->rdb);
G_OBJECT_CLASS (rb_dacp_player_parent_class)->finalize (object);
}
@@ -259,6 +261,9 @@ rb_dacp_player_new (RBShell *shell)
player = RB_DACP_PLAYER (g_object_new (RB_TYPE_DACP_PLAYER, NULL));
+ g_object_get (shell,
+ "db", &player->priv->rdb,
+ NULL);
player->priv->shell = g_object_ref (shell);
player->priv->shell_player = g_object_ref (rb_shell_get_player (shell));
g_signal_connect_object (player->priv->shell_player,
@@ -294,7 +299,32 @@ rb_dacp_player_now_playing_record (DACPPlayer *player)
static gchar *
rb_dacp_player_now_playing_artwork (DACPPlayer *player, guint width, guint height)
{
- return NULL;
+ /* We are told the requested size, but we can ignore it as
+ libdmapsharing will shrink the image for us */
+ GValue *md;
+ gchar *cover;
+ RhythmDBEntry *entry;
+ const char *uri;
+
+ entry = rb_shell_player_get_playing_entry (RB_DACP_PLAYER (player)->priv->shell_player);
+ if (entry == NULL)
+ return NULL;
+
+ md = rhythmdb_entry_request_extra_metadata (RB_DACP_PLAYER (player)->priv->rdb, entry, RHYTHMDB_PROP_COVER_ART_URI);
+ rhythmdb_entry_unref (entry);
+
+ if (md == NULL)
+ return NULL;
+
+ uri = g_value_get_string (md);
+ cover = NULL;
+ if (g_ascii_strncasecmp(uri, "file://", 7) == 0) {
+ /* Need to remove file:// and unencode it, e.g. %20 to space */
+ cover = g_strdup(g_filename_from_uri(uri, NULL, NULL));
+ }
+ g_value_unset (md);
+ g_free (md);
+ return cover;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]