internal DACPRequest GetCueSongRequest(DACPQueryElement query, string sort, int index) { DACPRequest request = GetCueRequest(query, sort); request.QueryParameters["index"] = index.ToString(); return(request); }
internal DACPRequest GetCueShuffleRequest(DACPQueryElement query, string sort) { DACPRequest request = GetCueRequest(query, sort); request.QueryParameters["dacp.shufflestate"] = "1"; return(request); }
internal DACPRequest GetPlayQueueEditRequest(string command, DACPQueryElement query, PlayQueueMode mode, string sort = null) { DACPRequest request = new DACPRequest("/ctrl-int/1/playqueue-edit"); request.QueryParameters["command"] = command; if (query != null) { request.QueryParameters["query"] = query.ToString(); } request.QueryParameters["mode"] = ((int)mode).ToString(); if (sort != null) { request.QueryParameters["sort"] = sort; } if (this != Server.MainDatabase) { request.QueryParameters["srcdatabase"] = "0x" + PersistentID.ToString("x16"); } // TODO: Handle this separately if (mode == PlayQueueMode.Replace) { request.QueryParameters["clear-previous"] = "1"; } return(request); }
internal DACPRequest GetComposersRequest(bool requestSortHeaders = false) { DACPRequest request = new DACPRequest("/databases/{0}/browse/composers", Database.ID); DACPQueryElement query = DACPQueryCollection.And(DACPQueryPredicate.IsNotEmpty("daap.songcomposer"), MediaKindQuery); request.QueryParameters["filter"] = query.ToString(); if (requestSortHeaders) { request.QueryParameters["include-sort-headers"] = "1"; } return(request); }
public async Task <List <Audiobook> > SearchAudiobooksAsync(string searchString, CancellationToken cancellationToken) { DACPQueryElement query = DACPQueryCollection.And(DACPQueryPredicate.Is("daap.songalbum", searchString), MediaKindQuery); DACPRequest request = GetGroupsRequest(query, false, "albums"); request.CancellationToken = cancellationToken; try { var response = await Server.SubmitRequestAsync(request).ConfigureAwait(false); return(DACPUtility.GetItemsFromNodes(response.Nodes, n => new Audiobook(this, n)).ToList()); } catch { return(null); } }
public async Task <bool> PlaySong(Song song) { try { int index = IndexOf(song); DACPQueryElement query = DACPQueryCollection.And(DACPQueryPredicate.Is("dmap.itemname", _searchString), Database.MusicContainer.MediaKindQuery); DACPRequest request = Database.GetCueSongRequest(query, "name", index); await Database.Server.SubmitRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <List <Song> > SearchSongsAsync(string searchString, CancellationToken cancellationToken) { DACPQueryElement query = DACPQueryCollection.And(DACPQueryPredicate.Is("dmap.itemname", searchString), MediaKindQuery); DACPRequest request = GetItemsRequest(query, "name", false); request.CancellationToken = cancellationToken; try { var response = await Server.SubmitRequestAsync(request).ConfigureAwait(false); return(DACPUtility.GetItemsFromNodes(response.Nodes, n => new Song(this, n)).ToList()); } catch { return(null); } }
private DACPRequest GetCueRequest(DACPQueryElement query, string sort) { DACPRequest request = new DACPRequest("/ctrl-int/1/cue"); request.QueryParameters["command"] = "play"; if (query != null) { request.QueryParameters["query"] = query.ToString(); } request.QueryParameters["sort"] = sort; request.QueryParameters["srcdatabase"] = "0x" + PersistentID.ToString("x16"); request.QueryParameters["clear-first"] = "1"; return(request); }
internal DACPRequest GetItemsRequest(DACPQueryElement query, string sort = "album", bool requestSortHeaders = false) { // Apple's Remote uses the Base Playlist ID here rather than the actual container ID. DACPRequest request = new DACPRequest("/databases/{0}/containers/{1}/items", Database.ID, Database.BasePlaylist.ID); request.QueryParameters["meta"] = ItemsMeta; request.QueryParameters["type"] = "music"; request.QueryParameters["sort"] = sort; if (requestSortHeaders) { request.QueryParameters["include-sort-headers"] = "1"; } if (query != null) { request.QueryParameters["query"] = query.ToString(); } return(request); }
internal DACPRequest GetGroupsRequest(DACPQueryElement query, bool includeSortHeaders = false, string groupType = "albums") { DACPRequest request = new DACPRequest("/databases/{0}/groups", Database.ID); request.QueryParameters["meta"] = GroupsMeta; request.QueryParameters["type"] = "music"; request.QueryParameters["group-type"] = groupType; if (includeSortHeaders) { request.QueryParameters["include-sort-headers"] = "1"; } request.QueryParameters["sort"] = "album"; if (query != null) { request.QueryParameters["query"] = query.ToString(); } return(request); }
public void Add(DACPQueryElement element) { _elements.Add(element); }
internal Task <List <T> > GetGroupsAsync <T>(DACPQueryElement query, Func <DACPNodeDictionary, T> itemGenerator) { DACPRequest request = GetGroupsRequest(query); return(Server.GetListAsync(request, itemGenerator)); }