public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems) { Player player; if (modItems.Any()) { player = modItems.First() as Player; } else { IList <Player> availablePlayers = Player.GetAllConnectedPlayers(); if (availablePlayers.Count > 0) { player = availablePlayers[0]; } else { throw new Exception("Could not play items. No player found"); } } if (items.First() is MusicItem) { Server.Instance.LoadItemsToPlayer(player, items.OfType <MusicItem> ()); } else if (items.First() is RadioSubItem) { Server.Instance.ExecuteCommand(string.Format("{0} {1} playlist play item_id:{2}", player.Id, (items.First() as RadioSubItem).GetSuper().Command, (items.First() as RadioSubItem).IdPath)); } return(null); }
public override void UpdateItems() { items.Clear(); // Add artists albums.Clear(); albums.AddRange(Server.Instance.GetAlbums()); // Add albums artists.Clear(); artists.AddRange(Server.Instance.GetArtists()); // Add radios and all children foreach (RadioSuperItem r in Server.Instance.GetRadios()) { #if VERBOSE_OUTPUT Console.WriteLine("SQC: Adding radio:" + r.Name + " Children: " + r.GetChildrenRecursive().Length); #endif // items.Add (r); items.AddRange(r.GetChildrenRecursive()); } // Add players items.AddRange(Player.GetAllConnectedPlayers().Cast <Item> ()); // Add browse features items.Add(new BrowseAlbumsMusicItem()); items.Add(new BrowseArtistsMusicItem()); // Add artists and albums to items items.Capacity = Math.Max(items.Capacity, items.Count + albums.Count + artists.Count); foreach (Item album in albums) { items.Add(album); } foreach (Item artist in artists) { items.Add(artist); } }
public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems) { SqueezeCenter.Player player; if (modItems.Any()) { player = modItems.First() as Player; } else { Player[] availablePlayers = Player.GetAllConnectedPlayers(); if (availablePlayers.Length > 0) { player = availablePlayers[0]; } else { throw new Exception("Could not enqueue items. No player found"); } } Server.Instance.AddItemsToPlayer(player, items.Cast <MusicItem>()); return(null); }