pub struct NowPlaying {Show 27 fields
pub name: String,
pub artist_name: String,
pub album_name: String,
pub artwork: Artwork,
pub duration_in_millis: u64,
pub play_params: Option<PlayParams>,
pub url: Option<String>,
pub isrc: Option<String>,
pub current_playback_time: f64,
pub remaining_time: f64,
pub shuffle_mode: u8,
pub repeat_mode: u8,
pub in_favorites: bool,
pub in_library: bool,
pub genre_names: Vec<String>,
pub track_number: u32,
pub disc_number: u32,
pub release_date: Option<String>,
pub audio_locale: Option<String>,
pub composer_name: Option<String>,
pub has_lyrics: bool,
pub has_time_synced_lyrics: bool,
pub is_vocal_attenuation_allowed: bool,
pub is_mastered_for_itunes: bool,
pub is_apple_digital_master: bool,
pub audio_traits: Vec<String>,
pub previews: Vec<Preview>,
}Expand description
Currently playing track information returned by GET /now-playing.
This is an Apple Music API–style resource enriched with live playback
state (current_playback_time, remaining_time, shuffle_mode, etc.).
All fields use #[serde(default)] so deserialization succeeds even when
the API omits fields (e.g. radio stations may lack artist_name).
§Examples
println!("{} — {} ({})", track.name, track.artist_name, track.album_name);
println!("Position: {:.1}s / {}ms", track.current_playback_time, track.duration_in_millis);
if let Some(id) = track.song_id() {
println!("Song ID: {id}");
}
println!("Artwork: {}", track.artwork_url(600));Fields§
§name: StringSong name.
artist_name: StringArtist name.
album_name: StringAlbum name.
artwork: ArtworkArtwork information.
duration_in_millis: u64Total duration in milliseconds.
play_params: Option<PlayParams>Play parameters containing the song ID and kind.
url: Option<String>Apple Music web URL for the track.
isrc: Option<String>International Standard Recording Code.
current_playback_time: f64Current playback position in seconds.
remaining_time: f64Remaining playback time in seconds.
shuffle_mode: u8Shuffle mode — 0 = off, 1 = on.
repeat_mode: u8Repeat mode — 0 = off, 1 = repeat one, 2 = repeat all.
in_favorites: boolWhether the track is in the user’s favorites.
in_library: boolWhether the track is in the user’s library.
genre_names: Vec<String>Genre names (e.g. ["Electronic", "Music"]).
track_number: u32Track number on the album.
disc_number: u32Disc number on the album.
release_date: Option<String>Release date as an ISO-8601 string (e.g. "2016-05-27T12:00:00Z").
audio_locale: Option<String>Audio locale code (e.g. "en-US").
composer_name: Option<String>Composer / songwriter name.
has_lyrics: boolWhether the track has lyrics.
has_time_synced_lyrics: boolWhether the track has time-synced (karaoke-style) lyrics.
is_vocal_attenuation_allowed: boolWhether vocal attenuation (sing-along mode) is available.
is_mastered_for_itunes: boolLegacy flag — replaced by is_apple_digital_master.
is_apple_digital_master: boolWhether the track is an Apple Digital Master (high-resolution master).
audio_traits: Vec<String>Audio traits (e.g. ["atmos", "lossless", "lossy-stereo", "spatial"]).
previews: Vec<Preview>Audio preview URLs.
Implementations§
Source§impl NowPlaying
impl NowPlaying
Sourcepub fn song_id(&self) -> Option<&str>
pub fn song_id(&self) -> Option<&str>
Get the song ID from play_params, if present.
Sourcepub fn current_position_ms(&self) -> u64
pub fn current_position_ms(&self) -> u64
Get the current playback position in milliseconds.
Negative current_playback_time values (possible at seek boundaries)
are clamped to zero.
Sourcepub fn artwork_url(&self, size: u32) -> String
pub fn artwork_url(&self, size: u32) -> String
Get the artwork URL at the specified square size (in pixels).
Shorthand for self.artwork.url_for_size(size).
Trait Implementations§
Source§impl Clone for NowPlaying
impl Clone for NowPlaying
Source§fn clone(&self) -> NowPlaying
fn clone(&self) -> NowPlaying
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more