Restart same-track playback when looped state resumes
This commit is contained in:
@@ -1090,7 +1090,23 @@ async fn run_connection(
|
|||||||
if !loaded_new_track {
|
if !loaded_new_track {
|
||||||
match ps {
|
match ps {
|
||||||
2 => {
|
2 => {
|
||||||
if current_playing_state == 3 {
|
let status = player.status();
|
||||||
|
let should_restart_same_track = current_track.is_some()
|
||||||
|
&& (track_ended || status.state == PlayerState::Stopped);
|
||||||
|
|
||||||
|
if should_restart_same_track {
|
||||||
|
let restart_pos = requested_pos.unwrap_or(0);
|
||||||
|
info!(
|
||||||
|
"[STATE] Restarting current track from {}ms (ended={} player_state={:?})",
|
||||||
|
restart_pos,
|
||||||
|
track_ended,
|
||||||
|
status.state
|
||||||
|
);
|
||||||
|
player.send(PlayerCommand::Seek(restart_pos));
|
||||||
|
current_playing_state = 2;
|
||||||
|
current_position_ms = restart_pos;
|
||||||
|
track_ended = false;
|
||||||
|
} else if current_playing_state == 3 {
|
||||||
info!("[STATE] Resuming playback");
|
info!("[STATE] Resuming playback");
|
||||||
player.send(PlayerCommand::Resume);
|
player.send(PlayerCommand::Resume);
|
||||||
current_playing_state = 2;
|
current_playing_state = 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user