Automatically start playing in skip_to
This commit is contained in:
@ -71,6 +71,7 @@ pub fn skip_to(time: f64) {
|
||||
GlobalState::play_status().update(|status| {
|
||||
if let Some(audio) = status.get_audio() {
|
||||
audio.set_current_time(time);
|
||||
status.playing = true;
|
||||
log!("Player skipped to time: {}", time);
|
||||
} else {
|
||||
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
|
||||
log!("Skipping to start of current song");
|
||||
skip_to(0.0);
|
||||
status.update(|status| status.playing = true);
|
||||
};
|
||||
|
||||
let skip_forward = move |_| {
|
||||
if let Some(duration) = get_song_time_duration() {
|
||||
skip_to(duration.1);
|
||||
status.update(|status| status.playing = true);
|
||||
} else {
|
||||
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() {
|
||||
let time = duration.1 * percentage / 100.0;
|
||||
skip_to(time);
|
||||
GlobalState::play_status().update(|status| status.playing = true);
|
||||
} else {
|
||||
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;
|
||||
time = time.clamp(0.0, duration.1);
|
||||
skip_to(time);
|
||||
status.update(|status| status.playing = true);
|
||||
} else {
|
||||
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;
|
||||
time = time.clamp(0.0, duration.1);
|
||||
skip_to(time);
|
||||
status.update(|status| status.playing = true);
|
||||
} else {
|
||||
error!("Unable to skip backward: Unable to get current duration");
|
||||
}
|
||||
|
Reference in New Issue
Block a user