public async void UpdateTrack(Track track)
        {
            _currentTrack = track;

            advertLabel.Text = track.IsAd() ? "ADVERT" : "";
            timeProgressBar.Maximum = track.Length;

            if (track.IsAd())
                return; //Don't process further, maybe null values

            titleLinkLabel.Text = track.TrackResource.Name;
            titleLinkLabel.Tag = track.TrackResource.Uri;

            artistLinkLabel.Text = track.ArtistResource.Name;
            artistLinkLabel.Tag = track.ArtistResource.Uri;

            albumLinkLabel.Text = track.AlbumResource.Name;
            albumLinkLabel.Tag = track.AlbumResource.Uri;

            SpotifyUri uri = track.TrackResource.ParseUri();

            trackInfoBox.Text = $@"Track Info - {uri.Id}";

            bigAlbumPicture.Image = await track.GetAlbumArtAsync(AlbumArtSize.Size640);
            smallAlbumPicture.Image = await track.GetAlbumArtAsync(AlbumArtSize.Size160);
        }
    private void SetTrack(SpotifyAPI.Local.Models.Track t)
    {
        if (t == null)
        {
            return;
        }

        CurrentTrack = new Track(t);
        OnTrackChanged?.Invoke(CurrentTrack);

        Analysis.Log($"Set current track to '{CurrentTrack.Artist} - {CurrentTrack.Title}'");
    }
        public async void UpdateTrack(Track track)
        {
            _currentTrack = track;

            titleLinkLabel.Text = track.TrackResource.Name;
            titleLinkLabel.Tag = track.TrackResource.Uri;

            artistLinkLabel.Text = track.ArtistResource.Name;
            artistLinkLabel.Tag = track.ArtistResource.Uri;

            albumLinkLabel.Text = track.AlbumResource.Name;
            albumLinkLabel.Tag = track.AlbumResource.Uri;

            timeProgressBar.Maximum = track.Length;

            bigAlbumPicture.Image = await track.GetAlbumArtAsync(AlbumArtSize.Size640);
            smallAlbumPicture.Image = await track.GetAlbumArtAsync(AlbumArtSize.Size160);
        }
Example #4
0
    public Track(SpotifyAPI.Local.Models.Track t)
    {
        m_originalTrack = t;

        if (t.TrackResource != null)
        {
            Title    = t.TrackResource.Name;
            TrackURL = t.TrackResource.Location.Og;
            TrackUri = t.TrackResource.Uri;
        }
        if (t.ArtistResource != null)
        {
            Artist    = t.ArtistResource.Name;
            ArtistUri = t.ArtistResource.Uri;
        }
        if (t.AlbumResource != null)
        {
            Album    = t.AlbumResource.Name;
            AlbumUri = t.AlbumResource.Uri;
        }

        TotalTime = t.Length;
    }
Example #5
0
        public void Start()
        {
            if (!api.IsSpotifyRunning())
            {
                DialogResult q = MessageBox.Show("Spotify is not running! Would you like to start it now?", "Spotify not running!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (q == DialogResult.Yes)
                {
                    api.RunSpotify();
                    if (!api.IsSpotifyWebHelperRunning())
                        api.RunSpotifyWebHelper();

                }
                else if (q == DialogResult.No)
                {
                    Environment.Exit(0);
                }
            }

            _spotify = new api();

            _spotify.Connect();

            _spotify.OnTrackChange += new api.TrackChangeEventHandler(onTrackChange);
            _spotify.ListenForEvents = true;

            _currentTrack = _spotify.GetStatus().Track;

            WriteWithColor("+---------------------------+\n| ######################### |\n| ###### Spotify? ######### |\n| ######### Shut up! ###### |\n| ######################### |\n+---------------------------+", ConsoleColor.Gray);
            WriteWithColor("  Created by iUltimateLP @ GitHub [Compiled 10/28/15]", ConsoleColor.Gray);
            WriteWithColor("\nType 'help' for help.", ConsoleColor.Gray);

            checkAdStateTimer = new System.Timers.Timer();
            checkAdStateTimer.Interval = 500;
            checkAdStateTimer.Elapsed += new System.Timers.ElapsedEventHandler(CheckAdStateTimer_Elapsed);
            checkAdStateTimer.Enabled = true;

            KeepConsoleRunning();
        }
Example #6
0
 private void cTrdConnection_Callback()
 {
     try
     {
         cMREReady.Reset();
         cMRERunning.Set();
         while (!cMREStop.WaitOne(100))
         {
             if(!cBlnConnected)
             {
                 cBlnConnected = Connect();
                 if(cBlnConnected)
                 {
                     StatusResponse pSReStatus = cSLlLocalAPI.GetStatus();
                     cTrkCurrentlyPlaying = pSReStatus.Track;
                     if (Connected != null)
                     {
                         Connected(this, EventArgs.Empty);
                     }
                 }
                 Thread.Sleep(1000);
             }
             else
             {
                 StatusResponse pSReStatus = cSLlLocalAPI.GetStatus();
                 cBlnConnected = (pSReStatus != null);
                 if (!cBlnConnected)
                 {
                     if (Disconnected != null)
                     {
                         Disconnected(this, EventArgs.Empty);
                     }
                 }
                 Thread.Sleep(2000);
             }
         }
     }
     catch(Exception ex)
     {
         //An error occurred
     }
     finally
     {
         cMREStop.Reset();
         cMRERunning.Reset();
         cMREReady.Set();
     }
 }
Example #7
0
        private void CSLlLocalAPI_OnTrackChange(TrackChangeEventArgs e)
        {
            cTrkCurrentlyPlaying = e.NewTrack;
            MonitorTrackChangedEventArgs pArgArgs = new MonitorTrackChangedEventArgs()
            {
                CurrentTrack = cTrkCurrentlyPlaying,
                Skip = false
            };
            if(TrackChanged != null)
            {
                TrackChanged(this, pArgArgs);
            }

            if (pArgArgs.Skip)
            {
                cSLlLocalAPI.Skip();
            }
        }
Example #8
0
        private void CSLlLocalAPI_OnPlayStateChange(PlayStateEventArgs e)
        {
            if (e.Playing)
            {
                StatusResponse pSReStatus = cSLlLocalAPI.GetStatus();
                if(pSReStatus!= null)
                {
                    cTrkCurrentlyPlaying = pSReStatus.Track;
                    MonitorTrackChangedEventArgs pArgArgs = new MonitorTrackChangedEventArgs()
                    {
                        CurrentTrack = cTrkCurrentlyPlaying,
                        Skip = false
                    };
                    if (TrackChanged != null)
                    {
                        TrackChanged(this, pArgArgs);
                    }

                    if (pArgArgs.Skip)
                    {
                        cSLlLocalAPI.Skip();
                    }
                }
            }
        }
 public void UpdateTrack(Track track)
 {
     _currentTrack = track;
 }
Example #10
0
        public void ShowUpdatedTrack(Track track, bool isDisplayed)
        {
            string pendingMessage = "";

            if (track.IsAd())
                return; // Don't process further, maybe null values

            // display track
            Console.WriteLine("Song: " + track.TrackResource.Name);
            Console.WriteLine("Artist: " + track.ArtistResource.Name);
            Console.WriteLine("Album: " + track.AlbumResource.Name + "\n");

            // if song is allowed to be displayed to the chat
            if (isDisplayed)
            {
                pendingMessage = "Current Song: " + track.TrackResource.Name
                    + " || Artist: " + track.ArtistResource.Name
                    + " || Album: " + track.AlbumResource.Name;

                Program._lstTupDelayMsg.Add(new Tuple<string, DateTime>(
                        pendingMessage,
                        DateTime.Now.AddSeconds(Program._intStreamLatency)
                    )
                );
            }
        }
        public Task<string> GetArtworkAsync(Track track)
        {
            var albumArtUrl = track.GetAlbumArtUrl(AlbumArtSize.Size160);

            return GetArtworkAsync(albumArtUrl, track.TrackResource.Uri);
        }