feat(player): preview indicator in player bar + smart stop semantics (#394)

* feat(player): preview-active state on play button (ring + stop icon)

Checkpoint: play button mirrors the inline preview button from tracklists
during preview playback — hollow circle, accent ring depleting over the
preview duration, Square (stop) icon. Click still resumes main playback,
which the Rust audio engine cancels the preview for.

i18n key player.previewActive in all 8 locales for tooltip + aria-label.


* feat(player): show preview track in player bar + smart stop semantics

The player-bar info cell (cover, title, artist) now mirrors the previewing
track during preview playback, with a small accent "Preview" pill above
the title and an accent top-border on the bar. Rating, fullscreen hint
and album/artist link clicks are suppressed while previewing — they
target the queued track, not the preview.

Stop semantics for the two transport buttons during preview:
- Big play button (Square+ring visual): stops preview, main auto-resumes
  if it was playing before. Matches the tracklist preview-button behaviour.
- Small Stop button: new audio_preview_stop_silent Rust command — stops
  preview AND leaves main paused, so "Stop = silence" actually goes silent.

previewStore now stores the full PreviewingTrack (id, title, artist,
coverArt) — the seven startPreview call sites pass it through.
i18n key player.previewLabel in all 8 locales.
This commit is contained in:
Frank Stellmacher
2026-05-01 12:57:34 +02:00
committed by GitHub
parent 9cef3da1bb
commit 20a083a9a6
18 changed files with 204 additions and 32 deletions
+19 -1
View File
@@ -5412,12 +5412,30 @@ pub async fn audio_preview_play(
#[tauri::command]
pub fn audio_preview_stop(app: AppHandle, state: State<'_, AudioEngine>) {
preview_stop_inner(&app, &state, true);
}
/// Like `audio_preview_stop` but leaves the main sink paused even if it had
/// been paused by `preview_pause_main`. Used by the player-bar Stop button so
/// "stop everything" actually goes silent — without this the engine would
/// auto-resume main playback the moment the preview ends and the user perceives
/// the click as having no effect.
#[tauri::command]
pub fn audio_preview_stop_silent(app: AppHandle, state: State<'_, AudioEngine>) {
preview_stop_inner(&app, &state, false);
}
fn preview_stop_inner(app: &AppHandle, state: &AudioEngine, resume_main: bool) {
state.preview_gen.fetch_add(1, Ordering::SeqCst);
let sink = state.preview_sink.lock().unwrap().take();
let id = state.preview_song_id.lock().unwrap().take();
if let Some(s) = sink { s.stop(); }
preview_resume_main(&state);
if resume_main {
preview_resume_main(state);
} else {
state.preview_main_resume.store(false, Ordering::Release);
}
if let Some(id) = id {
app.emit("audio:preview-end", PreviewEndPayload {
+1
View File
@@ -4599,6 +4599,7 @@ pub fn run() {
audio::audio_play_radio,
audio::audio_preview_play,
audio::audio_preview_stop,
audio::audio_preview_stop_silent,
audio::audio_set_crossfade,
audio::audio_set_gapless,
audio::audio_set_normalization,