Example #1
0
        private SpofyManager()
        {
            model = new SpofyModel();
            growl = new GrowlInterop();

            spotify = new SpotifyLocalAPIClass();
            if (!SpotifyLocalAPIClass.IsSpotifyRunning())
            {
                spotify.RunSpotify();
                Thread.Sleep(5000);
            }

            if (!SpotifyLocalAPIClass.IsSpotifyWebHelperRunning())
            {
                spotify.RunSpotifyWebHelper();
                Thread.Sleep(4000);
            }

            if (!spotify.Connect())
            {
                Boolean retry = true;
                while (retry)
                {
                    MessageBoxResult result = MessageBox.Show("SpotifyLocalAPIClass could'nt load!\nDo you want to retry?", "Error", MessageBoxButton.YesNo, MessageBoxImage.Error);
                    if (result == MessageBoxResult.Yes)
                    {
                        if (spotify.Connect())
                            retry = false;
                        else
                            retry = true;
                    }
                    else
                    {
                        App.Current.Shutdown();
                        //this.Close();
                        return;
                    }
                }
            }
            mh = spotify.GetMusicHandler();
            eh = spotify.GetEventHandler();
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();
            spotify = new SpotifyLocalAPIClass();
            if (!SpotifyLocalAPIClass.IsSpotifyRunning())
            {
                spotify.RunSpotify();
                Thread.Sleep(5000);
            }

            if (!SpotifyLocalAPIClass.IsSpotifyWebHelperRunning())
            {
                spotify.RunSpotifyWebHelper();
                Thread.Sleep(4000);
            }
                
            if(!spotify.Connect())
            {
                Boolean retry = true;
                while(retry)
                {
                    if (MessageBox.Show("SpotifyLocalAPIClass could'nt load!", "Error", MessageBoxButtons.RetryCancel) == System.Windows.Forms.DialogResult.Retry)
                    {
                        if(spotify.Connect())
                            retry = false;
                        else
                            retry = true;
                    }
                    else
                    {
                        this.Close();
                        return;
                    }
                }
            }
            mh = spotify.GetMusicHandler();
            eh = spotify.GetEventHandler();
        }
Example #3
0
        public Main()
        {
            updateCheck();
            spotify = new SpotifyLocalAPIClass();   //Creating a new instance of Spotify Local API

            if (!SpotifyLocalAPIClass.IsSpotifyRunning()) //If Spotify is not running then
            {
                spotify.RunSpotify(); //Run spotify

                Thread.Sleep(5000);
                if (!SpotifyLocalAPIClass.IsSpotifyRunning())
                {
                    MessageBox.Show("Spotify didn't open after 5 seconds, exiting");
                    Environment.Exit(1);
                }
            }
            if (!SpotifyLocalAPIClass.IsSpotifyWebHelperRunning())
            {
                spotify.RunSpotifyWebHelper(); //Run Spotify Web Helper

                Thread.Sleep(5000);
                if (!SpotifyLocalAPIClass.IsSpotifyWebHelperRunning())
                {
                    MessageBox.Show("Spotify Web Helper didn't open after 5 seconds, exiting");
                    Environment.Exit(2);
                }
            }

            if (!spotify.Connect())
            {
                Boolean retry = true;
                while (retry)
                {
                    if (MessageBox.Show("SLAPI couldn't load!", "Error", MessageBoxButtons.RetryCancel) == System.Windows.Forms.DialogResult.Retry)
                    {
                        if (spotify.Connect())
                            retry = false;
                        else
                            retry = true;
                    }
                    else
                    {
                        this.Close();
                        return;
                    }
                }
            }
            mh = spotify.GetMusicHandler();
            eh = spotify.GetEventHandler();
            InitializeComponent();
        }