private async void Form1_Load(object sender, EventArgs e) { spotify.Update(); progressBar1.Maximum = (int)mh.GetCurrentTrack().GetLength() * 100; pictureBox1.Image = await spotify.GetMusicHandler().GetCurrentTrack().GetAlbumArtAsync(AlbumArtSize.SIZE_160); pictureBox2.Image = await spotify.GetMusicHandler().GetCurrentTrack().GetAlbumArtAsync(AlbumArtSize.SIZE_640); linkLabel1.Text = mh.GetCurrentTrack().GetTrackName(); linkLabel1.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetTrackURI()); linkLabel2.Text = mh.GetCurrentTrack().GetArtistName(); linkLabel2.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetArtistURI()); linkLabel3.Text = mh.GetCurrentTrack().GetAlbumName(); linkLabel3.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetAlbumURI()); label9.Text = mh.IsPlaying().ToString(); label11.Text = ((int)(mh.GetVolume() * 100)).ToString(); label7.Text = mh.IsAdRunning().ToString(); eh.OnTrackChange += new SpotifyEventHandler.TrackChangeEventHandler(trackchange); eh.OnTrackTimeChange += new SpotifyEventHandler.TrackTimeChangeEventHandler(timechange); eh.OnPlayStateChange += new SpotifyEventHandler.PlayStateEventHandler(playstatechange); eh.OnVolumeChange += new SpotifyEventHandler.VolumeChangeEventHandler(volumechange); eh.SetSynchronizingObject(this); eh.ListenForEvents(true); }
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 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(); }
private async void main_Load(object sender, EventArgs e) { this.Text = "SpottyMP3 v2." + version; //Changes text to match version user is using addToLog("Initialization of SpottyMP3 v2." + version + " complete, enjoy!", logBox); spotify.Update(); adPlaying.Text = "AdPlaying: " + mh.IsAdRunning(); //Is an ad playing right now? songPlaying.Text = "Playing: " + mh.IsPlaying(); //Is a song playing right now? //If an add is not running then get the tracks image if (!mh.IsAdRunning()) { currentPicture.Image = await spotify.GetMusicHandler().GetCurrentTrack().GetAlbumArtAsync(AlbumArtSize.SIZE_160); } try { currentBar.Maximum = mh.GetCurrentTrack().GetLength() * 100; //Gets track length and sets the end of the track as maximum value of progress bar artistLinkLabel.Text = mh.GetCurrentTrack().GetArtistName(); //Gets Current tracks artist name artistLinkLabel.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetArtistURI()); songLinkLabel.Text = mh.GetCurrentTrack().GetTrackName(); //Gets Current tracks name songLinkLabel.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetTrackURI()); albumLinkLabel.Text = mh.GetCurrentTrack().GetAlbumName(); //Gets Current tracks album name albumLinkLabel.LinkClicked += (senderTwo, args) => Process.Start(mh.GetCurrentTrack().GetAlbumURI()); } catch (NullReferenceException) { } //Other contributers links, im going to add mine :) creatorLabel.LinkClicked += (senderTwo, args) => Process.Start("http://www.hackforums.net/showthread.php?tid=4819899"); downloadersourceLabel.LinkClicked += (senderTwo, args) => Process.Start("http://www.hackforums.net/showthread.php?tid=4497329"); ogcreatorLabel.LinkClicked += (senderTwo, args) => Process.Start("http://www.hackforums.net/showthread.php?tid=4506105"); redderLabel.LinkClicked += (senderTwo, args) => Process.Start("https://leakforums.net/user-49440"); client.DownloadProgressChanged += client_DownloadProgressChanged; client.DownloadFileCompleted += client_DownloadFileCompleted; eh.OnTrackChange += new SpotifyEventHandler.TrackChangeEventHandler(trackChange); eh.OnTrackTimeChange += new SpotifyEventHandler.TrackTimeChangeEventHandler(timeChange); eh.OnPlayStateChange += new SpotifyEventHandler.PlayStateEventHandler(playstateChange); eh.OnVolumeChange += new SpotifyEventHandler.VolumeChangeEventHandler(volumeChange); eh.SetSynchronizingObject(this); eh.ListenForEvents(true); if (string.IsNullOrWhiteSpace(Settings.Default.DownloadDestination)) //If there is no default download destination then set it to the program directory, else, set it to default download { browseForFolderBox.Text = System.AppDomain.CurrentDomain.BaseDirectory; } else { browseForFolderBox.Text = Settings.Default.DownloadDestination; } retryIfUnder1Mb.Checked = Settings.Default.DownloadRetry; liveDownloads.Checked = Settings.Default.DownloadAutomatically; showDownloadNotification.Checked = Settings.Default.DownloadNotifications; tt.AutoPopDelay = 5000; tt.InitialDelay = 1000; tt.ReshowDelay = 500; tt.SetToolTip(retryIfUnder1Mb, "Whether or not to retry downloading a song if it finishes downloading smaller than 1MB"); }