public void Run() { Services.Application.RunOnThread(() => { Rhythmbox.StartIfNeccessary(); Rhythmbox.Client(Command); }); }
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 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; } } } }
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); }