Exemplo n.º 1
0
        private async void UpdateTrack()
        {
            StatusResponse status = _spotify.GetStatus();

            if (status == null || status.Track == null)
            {
                model.IsAdPlaying = true;
                model.ArtistName  = "";
                model.Cover       = null;
                model.Image       = null;
                model.TrackName   = null;
                return;
            }
            else
            {
                model.IsAdPlaying = false;
            }

            if (
                //Is Ad Running
                (!status.NextEnabled && !status.PrevEnabled) ||
                (status.Track.AlbumResource == null || status.Track.ArtistResource == null)
                )
            {
                return; //TODO: better ad treatment
            }
            _currentTrack      = status.Track;
            _currentLargeCover = await _currentTrack.GetAlbumArtAsync(AlbumArtSize.Size640);

            _currentSmallCoverUrl = _currentTrack.GetAlbumArtUrl(AlbumArtSize.Size160);

            if (_currentTrack != null)
            {
                string artistName       = _currentTrack.ArtistResource.Name;
                string trackName        = _currentTrack.TrackResource.Name;
                double totalTimeSeconds = _currentTrack.Length;
                string totalTime        = formatTime(totalTimeSeconds);

                App.Current.MainWindow.Title = String.Format("{0} - {1} - {2}", appName, artistName, trackName);
                model.TrackName        = trackName;
                model.ArtistName       = artistName;
                model.TotalTimeSeconds = totalTimeSeconds;
                model.TotalTime        = totalTime;
                if (_currentLargeCover != null)
                {
                    model.Image = _currentLargeCover;
                }

                _growl.TrackChanged(artistName, trackName, _currentSmallCoverUrl);

                model.LastTrack = _currentTrack;
            }
        }
Exemplo n.º 2
0
        private async void UpdateTrack(Track track)
        {
            if (track != null && !mh.IsAdRunning())
            {
                string artistName       = track.GetArtistName();
                string trackName        = track.GetTrackName();
                double totalTimeSeconds = track.GetLength();
                string totalTime        = formatTime(totalTimeSeconds);

                App.Current.MainWindow.Title = String.Format("{0} - {1} - {2}", appName, artistName, trackName);
                model.TrackName        = trackName;
                model.ArtistName       = artistName;
                model.TotalTimeSeconds = totalTimeSeconds;
                model.TotalTime        = totalTime;
                model.Image            = await track.GetAlbumArtAsync(AlbumArtSize.SIZE_640);

                growl.TrackChanged(artistName, trackName, track.GetAlbumArtURL(AlbumArtSize.SIZE_160));

                model.LastTrack = track;
            }
        }