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
            }
        }
Beispiel #2
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
            }
        }