示例#1
0
 public void Run()
 {
     Services.Application.RunOnThread(() => {
         Rhythmbox.StartIfNeccessary();
         Rhythmbox.Client(Command);
     });
 }
示例#2
0
 public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
 {
     new Thread((ThreadStart) delegate {
         Rhythmbox.Client("--next --no-start");
     }).Start();
     return(null);
 }
示例#3
0
        public override void UpdateItems()
        {
            items.Clear();

            // Add volume and display controls.
            foreach (Item item in RhythmboxRunnableItem.Items)
            {
                items.Add(item);
            }

            // Add music data.
            Rhythmbox.LoadMusicData(out albums, out artists, out songs, out playlists);
            foreach (Item album in albums)
            {
                items.Add(album);
            }
            foreach (Item artist in artists)
            {
                items.Add(artist);
            }
            foreach (Item song in songs)
            {
                items.Add(song);
            }
            foreach (Item playlist in playlists)
            {
                items.Add(playlist);
            }

            // Add browse features.
            items.Add(new BrowseAlbumsMusicItem());
            items.Add(new BrowseArtistsMusicItem());
            items.Add(new BrowseSongsMusicItem());
            if (playlists.Count > 0)
            {
                // If Rhythmbox isn't running, or if there are DBus issues,
                // we don't want the "Browse by playlist" item to show up and be useless.
                // Instead, we only show it when it's populated.
                // Artists, albums and songs are fetched via XML and should never fail.
                items.Add(new BrowsePlaylistsMusicItem());
            }
        }
示例#4
0
        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);
        }
示例#5
0
        public static void PlayPlaylist(PlaylistMusicItem playlist)
        {
            if (MPRISPlaylists != null)
            {
                // We know the playlist's name (playlist.Name), but not its ID. The reason it is not stored in the MusicItem
                // is that if Rhythmbox is restarted while Do is running, the ID changes, and the Play action will fail.
                // In other words, Rhythmbox's MPRIS/DBus Playlist IDs are non-persistent.
                // To avoid problems, we only store the playlist name, and figure out the ID as required, so that it is always
                // up-to-date. This way, the Play action on playlists should always work, even when Rhythmbox is not running.

                Rhythmbox.StartIfNeccessary();

                foreach (Playlist pl in Playlists)
                {
                    if (pl.Name == playlist.Name)
                    {
                        MPRISPlaylists.ActivatePlaylist(pl.Id);
                        break;
                    }
                }
            }
        }
示例#6
0
        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);
        }
示例#7
0
        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);
                }
            }
        }