fix(slint): cast lyrics auto-follow + DLNA seekbar duration

- Lyrics auto-follow while casting: the local poll's cast-skip now runs BEFORE
  clear_remote_anchor() (it was wiping the anchor every 450ms), and the cast
  poll publishes its position via lyrics_sync::publish_remote_anchor each tick
  (the 30Hz engine extrapolates between ticks, like the QConnect path). Anchor
  cleared on disconnect so local lyrics resume.
- DLNA seekbar: many renderers report TrackDuration=0 in GetPositionInfo, which
  left the bar permanently full (position/0 -> clamp 1.0) with no total time.
  Fall back to the track's catalog duration when the renderer reports 0 (the
  renderer's position is still authoritative). Chromecast reports a real
  duration, so it's unaffected.

cc
This commit is contained in:
vicrodh committed 2026-06-18 14:50:48 -06:00
1 parent 2d4d4d0906
commit 2e990cbf07
2 files changed
+40 -8

No files matched your search

+30
View File
@@ -337,6 +337,8 @@ impl SlintCastService {
self.restore_qconnect().await;
self.inner.lock().await.qconnect_was_on_before_cast = false;
}
// Hand the lyrics position source back to the local player.
crate::lyrics_sync::clear_remote_anchor();
self.push_connection_state().await;
}
@@ -723,6 +725,21 @@ impl SlintCastService {
}
};
// Many DLNA renderers report TrackDuration as 0 / NOT_IMPLEMENTED in
// GetPositionInfo, which left the seekbar permanently full (position/0 ->
// clamped to 1.0) with no total time. Fall back to the track's catalog
// duration (the position from the renderer is still authoritative).
let duration = if duration > 0.0 {
duration
} else {
self.runtime
.core()
.current_track()
.await
.map(|t| t.duration_secs as f64)
.unwrap_or(0.0)
};
// Track-end detection (mirrors castStore): Chromecast {PLAYING,BUFFERING}
// -> IDLE; DLNA PLAYING -> {STOPPED, NO_MEDIA_PRESENT}. One-shot latch,
// reset on PLAYING.
@@ -744,6 +761,19 @@ impl SlintCastService {
ended
};
// Feed the lyrics engine our position so it auto-follows while casting
// (the local poll is skipped, so it can't drive lyrics). The 30Hz sync
// engine extrapolates between these 1s ticks, same as the QConnect path.
let now_ms = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_millis() as u64)
.unwrap_or(0);
crate::lyrics_sync::publish_remote_anchor(
(position.max(0.0) * 1000.0) as u64,
now_ms,
playing,
);
// Push position to CastState + the now-playing bar (the local poll is
// stopped while casting, so the cast poll drives the bar).
let weak = self.window.clone();
+10 -8
View File
@@ -3482,18 +3482,14 @@ pub fn start_poll_loop(
continue;
}
// Not in controller mode (no peer / returned to local): reset the
// peer-track edge var so re-entering the peer state refreshes meta.
last_peer_track_id = 0;
// Lyrics position source back to the local player (Q7 resolver).
crate::lyrics_sync::clear_remote_anchor();
// --- CAST mode: the cast service's own 1s poll owns the bar -------
// While a Chromecast/DLNA renderer is connected the local player is
// stopped, so the local path below would push position=0 /
// playing=false / local-volume every 450ms and fight the cast poll
// (the reported seekbar flicker, wrong play icon, dead volume bar).
// Skip it entirely; cast_service::poll_once drives the bar.
// (seekbar flicker, wrong play icon, dead volume bar). Skip it
// entirely; cast_service::poll_once drives the bar AND publishes the
// lyrics anchor. Checked BEFORE clear_remote_anchor() below so the
// local tick doesn't wipe the cast poll's lyrics anchor (auto-follow).
if let Some(cast) = crate::cast_service::service() {
if cast.is_casting().await {
last_track_id = 0;
@@ -3503,6 +3499,12 @@ pub fn start_poll_loop(
}
}
// Not in controller mode (no peer / returned to local): reset the
// peer-track edge var so re-entering the peer state refreshes meta.
last_peer_track_id = 0;
// Lyrics position source back to the local player (Q7 resolver).
crate::lyrics_sync::clear_remote_anchor();
let event = runtime.core().player().get_playback_event();
let track_id = event.track_id;