/// <summary> /// Updates and Fetches all current information about the current track etc. /// </summary> public void Update() { if (!SpotifyLocalAPIClass.IsSpotifyWebHelperRunning() || !SpotifyLocalAPIClass.IsSpotifyRunning()) { return; } mh.Update(rh.Update()); }
public SpotifyEventHandler(SpotifyLocalAPIClass api, SpotifyMusicHandler mh) { timer = new System.Timers.Timer(); timer.Interval = 50; timer.Elapsed += tick; timer.AutoReset = false; timer.Enabled = false; this.api = api; this.mh = mh; }
public SpotifyEventHandler(SpotifyLocalAPIClass api, SpotifyMusicHandler mh) { timer = new System.Timers.Timer(); timer.Interval = 50; timer.Elapsed += tick; timer.AutoReset = false; timer.Enabled = false; this.api = api; this.mh = mh; }
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(); }
internal async Task <string> QueryAsync(string request, bool oauth, bool cfid, int wait) { string parameters = "?&ref=&cors=&_=" + GetTimestamp(); if (request.Contains("?")) { parameters = parameters.Substring(1); } if (oauth) { parameters += "&oauth=" + oauthKey; } if (cfid) { parameters += "&csrf=" + cfidKey; } if (wait != -1) { parameters += "&returnafter=" + wait; parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap"; } string a = "http://" + host + ":4380/" + request + parameters; string response = ""; try { //Need to find a better solution using (var wc = new ExtendedWebClientInstance()) { if (SpotifyLocalAPIClass.IsSpotifyRunning()) { response = "[ " + await wc.DownloadStringTaskAsync(new Uri(a)) + " ]"; } } } catch (Exception ex) { Console.WriteLine(ex.Message); return(""); } return(response); }
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(); }
internal String query(string request, bool oauth, bool cfid, int wait) { string parameters = "?&ref=&cors=&_=" + GetTimestamp(); if (request.Contains("?")) { parameters = parameters.Substring(1); } if (oauth) { parameters += "&oauth=" + oauthKey; } if (cfid) { parameters += "&csrf=" + cfidKey; } if (wait != -1) { parameters += "&returnafter=" + wait; parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap"; } string a = "http://" + host + ":4380/" + request + parameters; string response = ""; try { //Need to find a better solution if (SpotifyLocalAPIClass.IsSpotifyRunning()) { response = "[ " + wc.DownloadString(a) + " ]"; } } catch (Exception z) { return(""); } return(response); }
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(); }