Skip() public method

public Skip ( ) : void
return void
Exemplo n.º 1
0
        private List <Result> GetPlaying()
        {
            var t = _api.CurrentTrack;

            if (t == null)
            {
                return(SingleResult("No track playing"));
            }

            var status       = _api.IsPlaying ? "Now Playing" : "Paused";
            var toggleAction = _api.IsPlaying ? "Pause" : "Resume";
            var icon         = _api.GetArtworkAsync(t);

            icon.Wait();

            return(new List <Result>()
            {
                new Result()
                {
                    Title = t.TrackResource.Name,
                    SubTitle = $"{status} | by {t.ArtistResource.Name}",
                    IcoPath = icon.Result
                },
                new Result()
                {
                    IcoPath = SpotifyIcon,
                    Title = "Pause / Resume",
                    SubTitle = $"{toggleAction}: {t.TrackResource.Name}",
                    Action = _ =>
                    {
                        if (_api.IsPlaying)
                        {
                            _api.Pause();
                        }
                        else
                        {
                            _api.Play();
                        }
                        return true;
                    }
                },
                new Result()
                {
                    IcoPath = SpotifyIcon,
                    Title = "Next",
                    SubTitle = $"Skip: {t.TrackResource.Name}",
                    Action = context =>
                    {
                        _api.Skip();
                        return true;
                    }
                },
                ToggleMute().First()
            });
        }
Exemplo n.º 2
0
        private List <Result> GetPlaying()
        {
            var d = _api.ActiveDeviceName;

            if (d == null)
            {
                //Must have an active device to control Spotify
                return(SingleResult("No active device", "Select device with `sp device`", () => {}));
            }

            var t = _api.PlaybackContext.Item;

            if (t == null)
            {
                return(SingleResult("No track playing", $"Active Device: {d}", () => {}));
            }

            var status       = _api.PlaybackContext.IsPlaying ? "Now Playing" : "Paused";
            var toggleAction = _api.PlaybackContext.IsPlaying ? "Pause" : "Resume";
            var icon         = _api.GetArtworkAsync(t);

            icon.Wait();

            return(new List <Result>()
            {
                new Result()
                {
                    Title = t.Name,
                    SubTitle = $"{status} | by {String.Join(", ",t.Artists.Select(a => String.Join("",a.Name)))}",
                    IcoPath = icon.Result
                },
                new Result()
                {
                    IcoPath = SpotifyIcon,
                    Title = "Pause / Resume",
                    SubTitle = $"{toggleAction}: {t.Name}",
                    Action = _ =>
                    {
                        if (_api.PlaybackContext.IsPlaying)
                        {
                            _api.Pause();
                        }
                        else
                        {
                            _api.Play();
                        }
                        return true;
                    }
                },
                new Result()
                {
                    IcoPath = SpotifyIcon,
                    Title = "Next",
                    SubTitle = $"Skip: {t.Name}",
                    Action = context =>
                    {
                        _api.Skip();
                        return true;
                    }
                },
                new Result()
                {
                    IcoPath = SpotifyIcon,
                    Title = "Last",
                    SubTitle = "Skip backwards",
                    Action = context =>
                    {
                        _api.SkipBack();
                        return true;
                    }
                },
                ToggleMute().First(),
                ToggleShuffle().First(),
                SetVolume().First()
            });
        }