public void Register(Dispatcher dispatcher) { spotify.Update(); UpdateTrack(mh.GetCurrentTrack()); eh.OnTrackChange += OnTrackChange; eh.OnPlayStateChange += OnPlayStateChange; eh.OnTrackTimeChange += OnTrackTimeChange; eh.SetSynchronizingObject(new DispatcherWinFormsCompatAdapter(dispatcher)); eh.ListenForEvents(true); }
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"); }