From 708b76ce1e5ab793c94ed52817ff9e175f871044 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 21 Mar 2014 23:38:14 +0100 Subject: [PATCH] Play only a single item when playspec has item-spec (Podcasts/Audiobooks) --- src/httpd_dacp.c | 7 +++---- src/player.c | 29 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index c39e8b2e..d03a6b0b 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -899,10 +899,9 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u if (!shuffle) { /* Start song ID */ - param = evhttp_find_header(query, "container-item-spec"); - if (!param) - param = evhttp_find_header(query, "item-spec"); - if (!param) + if ((param = evhttp_find_header(query, "item-spec"))) + plid = 0; // This is a podcast/audiobook - just play a single item, not a playlist + else if (!(param = evhttp_find_header(query, "container-item-spec"))) { DPRINTF(E_LOG, L_DACP, "No container-item-spec/item-spec in playspec request\n"); diff --git a/src/player.c b/src/player.c index 46a3b6ff..b8916ad0 100644 --- a/src/player.c +++ b/src/player.c @@ -849,17 +849,36 @@ player_queue_make_pl(int plid, uint32_t *id) struct player_source *ps; struct player_source *p; uint32_t i; + char buf[124]; memset(&qp, 0, sizeof(struct query_params)); - qp.id = plid; - qp.type = Q_PLITEMS; - qp.offset = 0; - qp.limit = 0; - qp.sort = S_NONE; + if (plid) + { + qp.id = plid; + qp.type = Q_PLITEMS; + qp.offset = 0; + qp.limit = 0; + qp.sort = S_NONE; + } + else if (*id) + { + qp.id = 0; + qp.type = Q_ITEMS; + qp.offset = 0; + qp.limit = 0; + qp.sort = S_NONE; + snprintf(buf, sizeof(buf), "f.id = %" PRIu32, *id); + qp.filter = strdup(buf); + } + else + return NULL; ps = player_queue_make(&qp, NULL); + if (qp.filter) + free(qp.filter); + /* Shortcut for shuffled playlist */ if (*id == 0) return ps;