Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions SpotifyAPI.Example/LocalControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ public async void UpdateTrack(Track track)
if (track.IsAd())
return; //Don't process further, maybe null values

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

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

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

SpotifyUri uri = track.TrackResource.ParseUri();
SpotifyUri uri = track.TrackResource?.ParseUri();

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

bigAlbumPicture.Image = await track.GetAlbumArtAsync(AlbumArtSize.Size640);
smallAlbumPicture.Image = await track.GetAlbumArtAsync(AlbumArtSize.Size160);
bigAlbumPicture.Image = track.AlbumResource != null ? await track.GetAlbumArtAsync(AlbumArtSize.Size640) : null;
smallAlbumPicture.Image = track.AlbumResource != null ? await track.GetAlbumArtAsync(AlbumArtSize.Size160) : null;
}

public void UpdatePlayingStatus(bool playing)
Expand Down
9 changes: 9 additions & 0 deletions SpotifyAPI/Local/Models/Track.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ public bool IsAd()
return true;
return false;
}

/// <summary>
/// Checks if the track id of type "other"
/// </summary>
/// <returns>true if the track is neither an advert nor a normal track, for example a podcast</returns>
public bool IsOtherTrackType()
{
return TrackType == "other";
}

/// <summary>
/// Returns a URL to the album cover in the provided size
Expand Down
3 changes: 2 additions & 1 deletion SpotifyAPI/Local/SpotifyLocalAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ private void ElapsedTick(object sender, ElapsedEventArgs e)
}
if (newStatusResponse.Track != null && _eventStatusResponse.Track != null)
{
if (newStatusResponse.Track.TrackResource?.Uri != _eventStatusResponse.Track.TrackResource?.Uri)
if (newStatusResponse.Track.TrackResource?.Uri != _eventStatusResponse.Track.TrackResource?.Uri ||
newStatusResponse.Track.IsOtherTrackType() && newStatusResponse.Track.Length != this._eventStatusResponse.Track.Length)
{
OnTrackChange?.Invoke(this, new TrackChangeEventArgs()
{
Expand Down