public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems) { new Thread((ThreadStart) delegate { Rhythmbox.StartIfNeccessary(); foreach (Item item in items) { string enqueue; enqueue = "--no-present "; foreach (SongMusicItem song in Rhythmbox.LoadSongsFor(item as MusicItem)) { enqueue += string.Format("--enqueue \"{0}\" ", song.File); } Rhythmbox.Client(enqueue); } }).Start(); return(null); }
public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems) { new Thread((ThreadStart) delegate { Rhythmbox.StartIfNeccessary(); Rhythmbox.Client("--pause --no-present"); Rhythmbox.Client("--clear-queue --no-present", true); if (items.Count() == 1 && items.ElementAt(0) is PlaylistMusicItem) { // Because playlists are not enqueued, but played as is, playing // more than one does not make any sense. Neither does playing e.g. // one playlist and two songs. // Therefore, only the case where the lone item selected is a playlist is supported. RhythmboxDBus.PlayPlaylist((PlaylistMusicItem)items.ElementAt(0)); } else { foreach (Item item in items) { if (item is MusicItem && !(item is PlaylistMusicItem)) { string enqueue = "--no-present "; foreach (SongMusicItem song in Rhythmbox.LoadSongsFor(item as MusicItem)) { enqueue = string.Format("{0} --enqueue \"{1}\" ", enqueue, song.File); } Rhythmbox.Client(enqueue, true); } } } Rhythmbox.Client("--next --no-present"); Rhythmbox.Client("--play --no-present"); }).Start(); return(null); }
public override IEnumerable <Item> ChildrenOfItem(Item parent) { if (IsRhythmbox(parent)) { yield return(new BrowseAlbumsMusicItem()); yield return(new BrowseArtistsMusicItem()); if (playlists.Count > 0) { yield return(new BrowsePlaylistsMusicItem()); } yield return(new BrowseSongsMusicItem()); foreach (Item item in RhythmboxRunnableItem.Items) { yield return(item); } } else if (parent is ArtistMusicItem) { foreach (AlbumMusicItem album in albums.Where(album => String.Equals(album.Artist, parent.Name, StringComparison.InvariantCultureIgnoreCase))) { yield return(album); } } else if (parent is AlbumMusicItem) { foreach (SongMusicItem song in Rhythmbox.LoadSongsFor(parent as AlbumMusicItem)) { yield return(song); } } else if (parent is BrowseAlbumsMusicItem) { foreach (AlbumMusicItem album in albums) { yield return(album); } } else if (parent is BrowseArtistsMusicItem) { foreach (ArtistMusicItem artist in artists) { yield return(artist); } } else if (parent is BrowseSongsMusicItem) { foreach (SongMusicItem song in songs) { yield return(song); } } else if (parent is BrowsePlaylistsMusicItem) { foreach (PlaylistMusicItem playlist in playlists) { yield return(playlist); } } }