private async void ConnectToLastFM_Click(object sender, RoutedEventArgs e)
        {
            LastFMScrobbler lastFm = new LastFMScrobbler(App.ApiKeyLastFm, "bd9ad107438d9107296ef799703d478e");

            string pseudo = (string)ApplicationSettingsHelper.ReadSettingsValue("LastFmUserName");
            string pd = (string)ApplicationSettingsHelper.ReadSettingsValue("LastFmPassword");

            if (string.IsNullOrEmpty(pseudo) || string.IsNullOrEmpty(pd)) return;
            ErrorConnectLastFmTextBox.Text = "Connecting";
            ErrorConnectLastFmTextBox.Visibility = Visibility.Visible;
            ErrorConnectLastFmTextBox.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
            var success = await lastFm.ConnectOperation(pseudo, pd);
            if (success)
            {
                ErrorConnectLastFmTextBox.Text = "";
                ErrorConnectLastFmTextBox.Visibility = Visibility.Collapsed;
                Locator.SettingsVM.LastFmIsConnected = true;
            }
            else
            {
                ErrorConnectLastFmTextBox.Foreground = new SolidColorBrush(Colors.Red);
                ErrorConnectLastFmTextBox.Text = "It didn't worked. Please check your credentials";
                Locator.SettingsVM.LastFmIsConnected = false;
            }
        }
Beispiel #2
0
        private async void UpdateLastFmOnNewTrack()
        {
            string pseudo = (string)ApplicationSettingsHelper.ReadSettingsValue("LastFmUserName");
            string pd = (string)ApplicationSettingsHelper.ReadSettingsValue("LastFmPassword");
            if (string.IsNullOrEmpty(pseudo) || string.IsNullOrEmpty(pd)) return;

            if (LastFMScrobbler == null)
            {
                // try to instanciate it
                LastFMScrobbler = new LastFMScrobbler("a8eba7d40559e6f3d15e7cca1bfeaa1c", "bd9ad107438d9107296ef799703d478e");
            }

            if (!LastFMScrobbler.IsConnected)
            {
                var success = await LastFMScrobbler.ConnectOperation(pseudo, pd);
                if (!success) return;
            }

            if (LastFMScrobbler != null && LastFMScrobbler.IsConnected)
            {
                LastFMScrobbler.ScrobbleTrack(((BackgroundTrackItem)Playlist.CurrentTrackItem).ArtistName, 
                                              ((BackgroundTrackItem)Playlist.CurrentTrackItem).AlbumName,
                                              ((BackgroundTrackItem)Playlist.CurrentTrackItem).Name);
            }
        }
Beispiel #3
0
        public async Task Scrobble()
        {
            if (!Locator.SettingsVM.LastFmIsConnected) return;
            if (LastFMScrobbler == null)
            {
                // try to instanciate it
                LastFMScrobbler = new LastFMScrobbler("a8eba7d40559e6f3d15e7cca1bfeaa1c", "bd9ad107438d9107296ef799703d478e");
            }

            if (!LastFMScrobbler.IsConnected)
            {
                var pseudo = Locator.SettingsVM.LastFmUserName;
                var pd = Locator.SettingsVM.LastFmPassword;
                var success = await LastFMScrobbler.ConnectOperation(pseudo, pd);
                if (!success) return;
            }

            if (LastFMScrobbler != null && LastFMScrobbler.IsConnected)
            {
                LastFMScrobbler.ScrobbleTrack(Locator.MusicPlayerVM.CurrentTrack.ArtistName,
                                                    Locator.MusicPlayerVM.CurrentTrack.AlbumName,
                                                    Locator.MusicPlayerVM.CurrentTrack.Name);
            }
        }