Esempio n. 1
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);
            }
        }
        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       = Strings.Connecting;
            ErrorConnectLastFmTextBox.Visibility = Visibility.Visible;
            ErrorConnectLastFmTextBox.Foreground = new SolidColorBrush(Colors.Gray);
            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       = Strings.CheckCredentials;
                Locator.SettingsVM.LastFmIsConnected = false;
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 4
0
        public async Task Scrobble()
        {
            if (!Locator.SettingsVM.LastFmIsConnected)
            {
                return;
            }
            try
            {
                if (LastFMScrobbler == null)
                {
                    // try to instanciate it
                    LastFMScrobbler = new LastFMScrobbler(App.ApiKeyLastFm, App.ApiSecretLastFm);
                }

                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)
                {
                    if (string.IsNullOrEmpty(Locator.MusicPlayerVM.CurrentTrack.ArtistName) || string.IsNullOrEmpty(Locator.MusicPlayerVM.CurrentTrack.AlbumName) || string.IsNullOrEmpty(Locator.MusicPlayerVM.CurrentTrack.Name))
                    {
                        return;
                    }
                    LastFMScrobbler.ScrobbleTrack(Locator.MusicPlayerVM.CurrentTrack.ArtistName,
                                                  Locator.MusicPlayerVM.CurrentTrack.AlbumName,
                                                  Locator.MusicPlayerVM.CurrentTrack.Name);
                }
            }
            catch { }
        }