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(); }
public void Play(string song) { if (SpotifyLocalAPIClass.IsValidSpotifyURI(song)) { musicHandler.PlayURL(song); } else { Console.WriteLine("Wrong format: " + song + " is not a spotify URI"); } }
public SpotifyMusicPlayer() { this.spotify = new SpotifyLocalAPIClass(); if (!spotify.Connect()) { Console.WriteLine("Spotify is not running"); Thread.Sleep(3000); return; } this.musicHandler = spotify.GetMusicHandler(); }
public void Initialize() { _lw = new LyricWrapper(); _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 couldn't load!", "Error", MessageBoxButton.OKCancel) == System.Windows.MessageBoxResult.Cancel) { if (_spotify.Connect()) { retry = false; } else { retry = true; } } else { this.Close(); return; } } } _spotify.Update(); _mh = _spotify.GetMusicHandler(); _eh = _spotify.GetEventHandler(); }
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(); }
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(); }