Exemplo n.º 1
0
        private void FetchSpotifyWeb()
        {
            SongFetcher sf   = new SongFetcher();
            TrackInfo   info = sf.FetchSpotifyWeb();

            if (info != null)
            {
                if (!info.isPlaying)
                {
                    if (Settings.CustomPauseTextEnabled)
                    {
                        WriteSong("", "", "");
                    }
                    return;
                }

                string albumUrl = null;

                if (info.albums.Count != 0)
                {
                    albumUrl = info.albums[0].Url;
                }

                if (info.DurationMS > 2000)
                {
                    if (!_songTimer.Enabled)
                    {
                        _songTimer.Enabled = true;
                    }
                    _songTimer.Stop();
                    _songTimer.Interval = info.DurationMS + 400;
                    _songTimer.Start();
                }

                WriteSong(info.Artists, info.Title, "", albumUrl, false, info.SongID, info.url);
            }
            else
            {
                if (!_songTimer.Enabled)
                {
                    _songTimer.Enabled = true;
                }
                _songTimer.Stop();
                _songTimer.Interval = 1000;
                _songTimer.Start();
            }
        }
Exemplo n.º 2
0
        private async Task GetCurrentSongAsync()
        {
            SongFetcher sf = new SongFetcher();
            SongInfo    songInfo;

            switch (_selectedSource)
            {
            case PlayerType.SpotifyLegacy:

                #region Spotify

                // Fetching the song thats currently playing on spotify
                // and updating the output on success
                songInfo = await sf.FetchDesktopPlayer("Spotify");

                if (songInfo != null)
                {
                    WriteSong(songInfo.Artist, songInfo.Title, songInfo.Extra, null, _firstRun);
                }

                break;

                #endregion Spotify

            case PlayerType.Youtube:

                #region YouTube

                // Fetching the song thats currently playing on youtube
                // and updating the output on success
                _temp = sf.FetchBrowser("YouTube");
                if (string.IsNullOrWhiteSpace(_temp))
                {
                    if (!string.IsNullOrWhiteSpace(_prevSong))
                    {
                        WriteSong(_prevSong, "", "", null, _firstRun);
                    }

                    break;
                }

                WriteSong("", _temp, "", null, _firstRun);

                break;

                #endregion YouTube


            case PlayerType.VLC:

                #region VLC

                songInfo = await sf.FetchDesktopPlayer("vlc");

                if (songInfo != null)
                {
                    WriteSong(songInfo.Artist, songInfo.Title, songInfo.Extra, null, _firstRun);
                }
                break;

                #endregion VLC

            case PlayerType.FooBar2000:

                #region foobar2000

                songInfo = await sf.FetchDesktopPlayer("foobar2000");

                if (songInfo != null)
                {
                    WriteSong(songInfo.Artist, songInfo.Title, songInfo.Extra, null, _firstRun);
                }

                break;

                #endregion foobar2000

            case PlayerType.Deezer:

                #region Deezer

                _temp = sf.FetchBrowser("Deezer");
                if (string.IsNullOrWhiteSpace(_temp))
                {
                    if (!string.IsNullOrWhiteSpace(_prevSong))
                    {
                        WriteSong(_prevSong, "", "", null, _firstRun);
                    }

                    break;
                }

                WriteSong(_temp, "", "", null, _firstRun);
                break;

                #endregion Deezer

            case PlayerType.SpotifyWeb:

                #region Spotify API

                FetchSpotifyWeb();
                break;

                #endregion Spotify API
            }
        }
Exemplo n.º 3
0
        private void GetCurrentSongAsync()
        {
            SongFetcher sf = new SongFetcher();

            string[] currentlyPlaying;
            switch (_selectedSource)
            {
            case PlayerType.SpotifyLegacy:

                #region Spotify

                // Fetching the song thats currently playing on spotify
                // and updating the output on success
                currentlyPlaying = sf.FetchDesktopPlayer("Spotify");
                if (currentlyPlaying != null)
                {
                    WriteSong(currentlyPlaying[0], currentlyPlaying[1], currentlyPlaying[2]);
                }
                break;

                #endregion Spotify

            case PlayerType.Youtube:

                #region YouTube

                // Fetching the song thats currently playing on youtube
                // and updating the output on success
                _temp = sf.FetchBrowser("YouTube");
                if (string.IsNullOrWhiteSpace(_temp))
                {
                    if (!string.IsNullOrWhiteSpace(_prevSong))
                    {
                        WriteSong(_prevSong, "", "");
                    }
                    break;
                }
                WriteSong(_temp, "", "");

                break;

                #endregion YouTube

            case PlayerType.Nightbot:

                #region Nightbot

                // Fetching the currently playing song on NB Song Request
                // and updating the output on success
                _temp = sf.FetchNightBot();
                if (String.IsNullOrWhiteSpace(_temp))
                {
                    if (!String.IsNullOrWhiteSpace(_prevSong))
                    {
                        WriteSong(_prevSong, "", "");
                    }
                    break;
                }
                WriteSong(_temp, "", "");

                break;

                #endregion Nightbot

            case PlayerType.VLC:

                #region VLC

                currentlyPlaying = sf.FetchDesktopPlayer("vlc");
                if (currentlyPlaying != null)
                {
                    WriteSong(currentlyPlaying[0], currentlyPlaying[1], currentlyPlaying[2]);
                }
                break;

                #endregion VLC

            case PlayerType.FooBar2000:

                #region foobar2000

                currentlyPlaying = sf.FetchDesktopPlayer("foobar2000");
                if (currentlyPlaying != null)
                {
                    WriteSong(currentlyPlaying[0], currentlyPlaying[1], currentlyPlaying[2]);
                }
                break;

                #endregion foobar2000

            case PlayerType.Deezer:

                #region Deezer

                _temp = sf.FetchBrowser("Deezer");
                if (string.IsNullOrWhiteSpace(_temp))
                {
                    if (!string.IsNullOrWhiteSpace(_prevSong))
                    {
                        WriteSong(_prevSong, "", "");
                    }
                    break;
                }
                WriteSong(_temp, "", "");
                break;

                #endregion Deezer

            case PlayerType.SpotifyWeb:

                #region Spotify API

                FetchSpotifyWeb();
                break;

                #endregion Spotify API
            }
        }