public async Task <bool> PlayItem(DACPItem item, PlayQueueMode mode = PlayQueueMode.Replace) { DACPRequest request; if (Server.SupportsPlayQueue) { request = Database.GetPlayQueueEditRequest("add", DACPQueryPredicate.Is("dmap.itemid", item.ID), mode, "name"); request.QueryParameters["queuefilter"] = string.Format("genre:{0}", Uri.EscapeDataString(DACPUtility.EscapeSingleQuotes(Name))); } else { var items = await GetItemsAsync(); int index = items.FindIndex(i => i.ID == item.ID); if (index < 0) { return(false); } request = Database.GetCueSongRequest(DACPQueryCollection.And(GenreQuery, Container.MediaKindQuery), "name", index); } try { await Server.SubmitRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> PlaySong(Song song, PlayQueueMode mode = PlayQueueMode.Replace) { DACPRequest request; if (Server.SupportsPlayQueue) { object songID; if (Server.IsAppleTV) { songID = song.PersistentID; } else { songID = song.ID; } request = Database.GetPlayQueueEditRequest("add", DACPQueryPredicate.Is("dmap.itemid", songID), mode, "album"); request.QueryParameters["queuefilter"] = string.Format("album:{0}", PersistentID); } else { var songs = await GetSongsAsync(); int index = songs.FindIndex(s => s.ID == song.ID); if (index < 0) { return(false); } request = Database.GetCueSongRequest(ItemQuery, "album", index); } try { await Server.SubmitRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> SendPlaySongCommandAsync(Song song, PlayQueueMode mode = PlayQueueMode.Replace) { DacpRequest request; if (Client.ServerSupportsPlayQueue) { request = Database.GetPlayQueueEditRequest("add", DacpQueryPredicate.Is("dmap.itemid", song.ID), mode, "album"); request.QueryParameters["queuefilter"] = string.Format("artist:{0}", ArtistID); } else { var songs = await GetSongsAsync().ConfigureAwait(false); int index = songs.FindIndex(s => s.ID == song.ID); if (index < 0) { return(false); } request = Database.GetCueSongRequest(ItemQuery, "album", index); } try { await Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> SendPlayQueueCommandAsync(PlayQueueMode mode = PlayQueueMode.Replace) { var query = DacpQueryPredicate.Is("dmap.itemid", ID); DacpRequest request = Database.GetPlayQueueEditRequest("add", query, mode); try { await Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> PlayQueue(PlayQueueMode mode = PlayQueueMode.Replace) { var query = DACPQueryPredicate.Is("dmap.itemid", ID); DACPRequest request = Database.GetPlayQueueEditRequest("add", query, mode); try { await Server.SubmitRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> Play(PlayQueueMode mode = PlayQueueMode.Replace) { DACPRequest request; if (Server.SupportsPlayQueue) { request = Database.GetPlayQueueEditRequest("add", GroupQuery, mode, "album"); } else { request = Database.GetCueSongRequest(ItemQuery, "album", 0); } try { await Server.SubmitRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> Play(PlayQueueMode mode = PlayQueueMode.Replace) { DACPRequest request; if (Server.SupportsPlayQueue) { request = Database.GetPlayQueueEditRequest("add", GenreQuery, mode, "name"); } else { request = Database.GetCueSongRequest(DACPQueryCollection.And(GenreQuery, Container.MediaKindQuery), "name", 0); } try { await Server.SubmitRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> SendPlayCommandAsync(PlayQueueMode mode = PlayQueueMode.Replace) { DacpRequest request; if (Client.ServerSupportsPlayQueue) { request = Database.GetPlayQueueEditRequest("add", GroupQuery, mode, "album"); } else { request = Database.GetCueSongRequest(ItemQuery, "album", 0); } try { await Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> SendPlayItemCommandAsync(DacpItem item, PlayQueueMode mode = PlayQueueMode.Replace) { DacpRequest request; if (Client.ServerSupportsPlayQueue) { var query = DacpQueryPredicate.Is("dmap.containeritemid", item.ContainerItemID); request = Database.GetPlayQueueEditRequest("add", query, mode, "physical"); request.QueryParameters["queuefilter"] = string.Format("playlist:{0}", ID); } else { request = GetPlaySpecRequest(); request.QueryParameters["container-item-spec"] = DacpQueryPredicate.Is("dmap.containeritemid", "0x" + item.ContainerItemID.ToString("x8")).ToString(); } try { await Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
public async Task <bool> SendPlayCommandAsync(PlayQueueMode mode = PlayQueueMode.Replace) { if (!Client.ServerSupportsPlayQueue) { // Send a play request for the first item in this playlist var items = await GetItemsAsync(); if (items == null || items.Count == 0) { return(false); } return(await SendPlayItemCommandAsync(items[0], mode).ConfigureAwait(false)); } var query = DacpQueryPredicate.Is("dmap.itemid", ID); DacpRequest request = Database.GetPlayQueueEditRequest("add", query, mode); request.QueryParameters["query-modifier"] = "containers"; try { await Client.SendRequestAsync(request).ConfigureAwait(false); } catch { return(false); } return(true); }
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); }