switch back to playlist change behavior from v0.20 but get right index, fix #619

This commit is contained in:
jb-alvarado 2024-04-26 09:42:33 +02:00
parent 7dcb8fce65
commit aeb5a1b5ea

View File

@ -112,24 +112,36 @@ impl CurrentProgram {
let (delta, total_delta) = get_delta(&self.config, &time_in_seconds()); let (delta, total_delta) = get_delta(&self.config, &time_in_seconds());
let mut next = false; let mut next = false;
trace!( let duration = if self.current_node.duration >= self.current_node.out {
"delta: {delta}, total_delta: {total_delta}, current index: {}", self.current_node.duration
self.current_node.index.unwrap_or_default() } else {
); // maybe out is longer to be able to loop
self.current_node.out
};
let mut clip_start = self.current_node.begin.unwrap_or_default() - self.start_sec; let node_index = self.current_node.index.unwrap_or_default();
if self.player_control.current_index.load(Ordering::SeqCst) trace!("delta: {delta}, total_delta: {total_delta}, current index: {node_index}",);
== self.player_control.current_list.lock().unwrap().len() - 1
let mut next_start =
self.current_node.begin.unwrap_or_default() - self.start_sec + duration + delta;
if node_index > 0
&& node_index == self.player_control.current_list.lock().unwrap().len() - 1
{ {
clip_start += self.config.general.stop_threshold; println!("add threshold!");
next_start += self.config.general.stop_threshold;
} }
trace!("clip_start: {clip_start}, end_sec: {}", self.end_sec); trace!(
"next_start: {next_start} | end_sec: {} | source {}",
self.end_sec,
self.current_node.source
);
// Check if we over the target length or we are close to it, if so we load the next playlist. // Check if we over the target length or we are close to it, if so we load the next playlist.
if !self.config.playlist.infinit if !self.config.playlist.infinit
&& (clip_start >= self.end_sec && (next_start >= self.end_sec
|| is_close(total_delta, 0.0, 2.0) || is_close(total_delta, 0.0, 2.0)
|| is_close(total_delta, self.end_sec, 2.0)) || is_close(total_delta, self.end_sec, 2.0))
{ {