コード例 #1
0
        static Worker()
        {
            LocalApi = new SpotifyAPI.Local.SpotifyLocalAPI();

            WebApi         = new SpotifyAPI.Web.SpotifyWebAPI();
            WebApi.UseAuth = false;
        }
コード例 #2
0
        private bool ConnectToSpotifyClient()
        {
            Debug.WriteLine("SpotifyManager:: Connect to client.");


            if (SpotLocalAPI.IsSpotifyRunning())
            {
                CommandOpenSpotify.Instance.m_currentTextlabel = CommandOpenSpotify.kSpotifyOpenString;
                if (spotClient == null)
                {
                    spotClient = new SpotLocalAPI();
                }

                bool connected = spotClient.Connect();
#if DEBUG
                Debug.WriteLine("Spotify Client Connected: {0}", connected);
                Debug.Assert(connected);
#endif
                if (connected)
                {
                    RegisterEvents();
                }
                spotClientConnected = connected;

                SettingsManager.GetSettingsManager().ApplyCurrentSettings();
                return(connected);
            }

            CommandOpenSpotify.Instance.m_currentTextlabel = CommandOpenSpotify.kSpotifyStartString;
            SettingsManager.GetSettingsManager().ApplyCurrentSettings();
            spotClientConnected = false;
            return(false);
        }
コード例 #3
0
        public static bool SpotifyConnect()
        {
            if (SpotifyAPI.Local.SpotifyLocalAPI.IsSpotifyRunning())
            {
                if (spotClient == null)
                {
                    spotClient = new SpotifyAPI.Local.SpotifyLocalAPI();
                }

                //if (spotWeb == null)
                //{
                //    AuthenticateSpotifyWeb();
                //   // MessageBox.Show(spotWeb.AccessToken);
                //}

                bool connected = spotClient.Connect();

#if DEBUG
                Console.WriteLine("Spotify Client Connected: {0}", connected);
                Debug.Assert(connected);
#endif
                spotClientConnected = connected;
                return(connected);
            }
            spotClientConnected = false;
            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command1"/> class.
        /// </summary>
        public Command1Package()
        {
            // Inside this method you can place any initialization code that does not require
            // any Visual Studio service because at this point the package object is created but
            // not sited yet inside Visual Studio environment. The place to do all the other
            // initialization is the Initialize method.

            // m_packageDTEEvents = ApplicationObject.Events.DTEEvents;
            // m_packageDTEEvents.OnBeginShutdown += new _dispDTEEvents_OnBeginShutdownEventHandler(HandleVisualStudioShutDown);

            spotClient = new SpotifyAPI.Local.SpotifyLocalAPI();
            spotClient.Connect();
        }
コード例 #5
0
 public bool GetSpotifyConnectionStatus()
 {
     if (spotClient != null && spotClientConnected)
     {
         if (spotClient.GetStatus() == null)
         {
             spotClient          = null;
             spotClientConnected = false;
             return(false);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #6
0
        public void OpenSpotify()
        {
            Debug.WriteLine("SpotifyManager:: OpenSpotify.");
            Process spotifyWindow = null;

            if ((spotifyWindow = GetSpotifyWindowProcess()) != null)
            {
                UnsafeNativeMethods.BringProcessToFront(spotifyWindow);
            }
            else if (!SpotLocalAPI.IsSpotifyRunning())
            {
                Debug.WriteLine("Spotify not running.");
                SpotLocalAPI.RunSpotify();

                System.Threading.Thread.Sleep(300);
                ConnectToSpotifyClient();

                // update command hidden states.
            }
        }
コード例 #7
0
 private void DisconnectSpotifyClient()
 {
     spotClient.Dispose();
     spotClient          = null;
     spotClientConnected = false;
 }
コード例 #8
0
 public SpotifyManager()
 {
     spotClient          = null;
     spotWeb             = null;
     spotClientConnected = false;
 }