Automatically start playing in skip_to

This commit is contained in:
2025-04-29 21:27:35 +00:00
parent 976790342c
commit cf35961516

View File

@ -71,6 +71,7 @@ pub fn skip_to(time: f64) {
GlobalState::play_status().update(|status| { GlobalState::play_status().update(|status| {
if let Some(audio) = status.get_audio() { if let Some(audio) = status.get_audio() {
audio.set_current_time(time); audio.set_current_time(time);
status.playing = true;
log!("Player skipped to time: {}", time); log!("Player skipped to time: {}", time);
} else { } else {
error!("Unable to skip to time: Audio element not available"); error!("Unable to skip to time: Audio element not available");
@ -119,13 +120,11 @@ fn PlayControls() -> impl IntoView {
// Default to skipping to start of current song, and playing // Default to skipping to start of current song, and playing
log!("Skipping to start of current song"); log!("Skipping to start of current song");
skip_to(0.0); skip_to(0.0);
status.update(|status| status.playing = true);
}; };
let skip_forward = move |_| { let skip_forward = move |_| {
if let Some(duration) = get_song_time_duration() { if let Some(duration) = get_song_time_duration() {
skip_to(duration.1); skip_to(duration.1);
status.update(|status| status.playing = true);
} else { } else {
error!("Unable to skip forward: Unable to get current duration"); error!("Unable to skip forward: Unable to get current duration");
} }
@ -355,7 +354,6 @@ fn ProgressBar(percentage: Signal<f64>) -> impl IntoView {
if let Some(duration) = get_song_time_duration() { if let Some(duration) = get_song_time_duration() {
let time = duration.1 * percentage / 100.0; let time = duration.1 * percentage / 100.0;
skip_to(time); skip_to(time);
GlobalState::play_status().update(|status| status.playing = true);
} else { } else {
error!("Unable to skip to time: Unable to get current duration"); error!("Unable to skip to time: Unable to get current duration");
} }
@ -424,7 +422,6 @@ pub fn PlayBar() -> impl IntoView {
let mut time = duration.0 + ARROW_KEY_SKIP_TIME; let mut time = duration.0 + ARROW_KEY_SKIP_TIME;
time = time.clamp(0.0, duration.1); time = time.clamp(0.0, duration.1);
skip_to(time); skip_to(time);
status.update(|status| status.playing = true);
} else { } else {
error!("Unable to skip forward: Unable to get current duration"); error!("Unable to skip forward: Unable to get current duration");
} }
@ -437,7 +434,6 @@ pub fn PlayBar() -> impl IntoView {
let mut time = duration.0 - ARROW_KEY_SKIP_TIME; let mut time = duration.0 - ARROW_KEY_SKIP_TIME;
time = time.clamp(0.0, duration.1); time = time.clamp(0.0, duration.1);
skip_to(time); skip_to(time);
status.update(|status| status.playing = true);
} else { } else {
error!("Unable to skip backward: Unable to get current duration"); error!("Unable to skip backward: Unable to get current duration");
} }