internal string GetString() #endif { switch (measureType) { case "trackname": case "track": return(parent.Status?.Track?.TrackResource?.Name ?? ""); case "artistname": case "artist": return(parent.Status?.Track?.ArtistResource?.Name ?? ""); case "albumname": case "album": return(parent.Status?.Track?.AlbumResource?.Name ?? ""); case "trackuri": return(parent.Status?.Track?.TrackResource?.Uri ?? ""); case "albumuri": return(parent.Status?.Track?.AlbumResource?.Uri ?? ""); case "artisturi": return(parent.Status?.Track?.ArtistResource?.Uri ?? ""); case "position": double playingPosition = (parent.Status?.PlayingPosition).GetValueOrDefault(); double sec = Math.Floor(playingPosition % 60); double min = Math.Floor(playingPosition / 60); return(String.Format("{0}:{1}", min.ToString("#00"), sec.ToString("00"))); case "duration": case "length": double trackLength = (parent.Status?.Track?.Length).GetValueOrDefault(); double secl = Math.Floor(trackLength % 60); double minl = Math.Floor(trackLength / 60); return(String.Format("{0}:{1}", minl.ToString("#00"), secl.ToString("00"))); // TODO case "albumart": case "cover": return(AlbumArt.getArt(parent.Status?.Track?.AlbumResource?.Uri, artResolution, defaultPath, coverPath)); } // MeasureType.Major, MeasureType.Minor, and MeasureType.Number are // numbers. Therefore, null is returned here for them. This is to // inform Rainmeter that it can treat those types as numbers. return(null); }
internal string GetString() #endif { switch (measureType) { case "trackname": case "track": return(parent.Status?.Item?.Name ?? ""); case "artistname": case "artist": var artists = parent.Status?.Item?.Artists; if (artists == null) { return(""); } string result = ""; foreach (SimpleArtist artist in artists) { if (result.Length != 0) { result += ", "; } result += artist.Name; } return(result); case "albumname": case "album": return(parent.Status?.Item?.Album?.Name ?? ""); case "trackuri": return(parent.Status?.Item?.Uri ?? ""); case "albumuri": return(parent.Status?.Item?.Album.Uri ?? ""); case "artisturi": // TODO //return parent.Status?.Track?.ArtistResource?.Uri ?? ""; return("not implemented yet"); case "position": TimeSpan position = TimeSpan.FromMilliseconds((parent.Status?.ProgressMs).GetValueOrDefault()); return(position.ToString(@"mm\:ss")); case "duration": case "length": TimeSpan duration = TimeSpan.FromMilliseconds((parent.Status?.Item?.DurationMs).GetValueOrDefault()); return(duration.ToString(@"mm\:ss")); // TODO case "albumart": case "cover": return(AlbumArt.getArt(parent.Status?.Item?.Album?.Uri, artResolution, defaultPath, coverPath)); } // MeasureType.Major, MeasureType.Minor, and MeasureType.Number are // numbers. Therefore, null is returned here for them. This is to // inform Rainmeter that it can treat those types as numbers. return(null); }