Exemple #1
0
        private static void GetSessionKey()
        {
            // try get the session key from the registry
            string sessionKey = GetRegistrySetting(sessionKeyRegistryKeyName, null);

            if (string.IsNullOrEmpty(sessionKey))
            {
                // instantiate a new scrobbler

                int  tried = 0;
                bool error = false;

                error = false;
                // Try get session key from Last.fm
                try
                {
                    sessionKey = scrobbler.GetSession();
                    var user = scrobbler.GetSessionUser();
                    // successfully got a key. Save it to the registry for next time
                    SetRegistrySetting(sessionKeyRegistryKeyName, sessionKey);
                    SetRegistrySetting("ScrobblerUser", user);
                    SetRegistrySetting("ScrobblerRealName", Services.User.GetRealName(user));
                    RaiseMySessionChangedEvent();
                }
                catch (LastFmApiException exception)
                {
                    error = true;
                }
                App.Current.Dispatcher.BeginInvoke(new Action(() => errormessage(!error)));
            }

            _scrobbler = new QueuingScrobbler(ApiKey, ApiSecret, sessionKey);
        }
Exemple #2
0
        public void Init()
        {
            if (Settings.Current.ScrobbleActive)
            {
                // instantiate a new scrobbler
                if (scrobbler == null)
                {
                    scrobbler = new Scrobbler(ApiKey, ApiSecret);
                }

                if (_scrobbler == null)
                {
                    string sessionKey = GetSessionKey();

                    if (!string.IsNullOrEmpty(sessionKey))
                    {
                        // instantiate the async scrobbler
                        _scrobbler = new QueuingScrobbler(ApiKey, ApiSecret, sessionKey);
                    }
                }
            }
        }
 private void InitScrobblers()
 {
     _scrobbler = new QueuingScrobbler(APIKey, APISecret, SessionKey);
 }