pub struct NowPlaying { /* private fields */ }Expand description
The banner’s whole state: what to announce, and how long ago it was set.
Implementations§
Source§impl NowPlaying
impl NowPlaying
Sourcepub fn set(&mut self, text: &str)
pub fn set(&mut self, text: &str)
Announce text, restarting the envelope.
Setting the string that is already set is a no-op, so a source that
re-reports the current track — SMTC fires MediaPropertiesChanged for
artwork and position updates too — cannot re-trigger the banner. An empty
or whitespace-only string clears it immediately.
Sourcepub fn advance(&mut self, dt: f32)
pub fn advance(&mut self, dt: f32)
Advance the envelope by dt real seconds. Non-finite or non-positive
steps are ignored, matching the parameter smoother’s rule.
Sourcepub fn alpha(&self) -> f32
pub fn alpha(&self) -> f32
The current opacity in 0.0..=1.0; zero when there is nothing to draw.
Sourcepub fn layout(&self, width: f32, height: f32) -> [Option<BannerLine<'_>>; 2]
pub fn layout(&self, width: f32, height: f32) -> [Option<BannerLine<'_>>; 2]
The two positioned lines to draw on a width×height surface, or
[None, None] while the banner is invisible.
The string splits on the first SEPARATOR into artist and title; a
string with no separator draws as a single title line. Both are truncated
to a character budget derived from the surface width, so a long title
ends in ... rather than running off the edge.