Exemplo n.º 1
0
        private void InitSpotifyClient()
        {
            if (SpotifySession == null)
            {
                LoadSettings();

                if (!EnsureTempPathOK())
                {
                    return;
                }

                if (string.IsNullOrEmpty(username))
                {
                    CF_displayMessage("Username not specified");
                    return;
                }

                CF_systemCommand(CF_Actions.SHOWINFO, "Connecting to Spotify");
                try
                {
                    SpotifySession = SpotiFire.SpotifyLib.Spotify.CreateSession(applicationKey, tempPath, tempPath, userAgent);
                }
                catch (Exception ex)
                {
                    CF_displayMessage(ex.Message);
                    WriteError(ex);
                    return;
                }
                finally
                {
                    CF_systemCommand(CF_Actions.HIDEINFO);
                }
                if (CF_getConnectionStatus())
                {
                    SpotifySession.SetConnectionType(ConnectionType.Wired);
                }
                else
                {
                    SpotifySession.SetConnectionType(ConnectionType.None);
                }
                SpotifySession.SetPrefferedBitrate(preferredBitrate);
                DistributeSessionForSubscription(SpotifySession);
            }
            if (!loginComplete)
            {
                LoadSettings();
                CF_systemCommand(CF_Actions.SHOWINFO, "Logging in");
                SpotifySession.Login(username, password, true);
            }
        }