update playlist and check for new one at the end, to prevent index out of bound

This commit is contained in:
jb-alvarado 2022-03-26 23:41:44 +01:00
parent 3ff8206ab4
commit 0fc5f6722f

View File

@ -228,9 +228,8 @@ impl Iterator for CurrentProgram {
return Some(self.current_node.clone()); return Some(self.current_node.clone());
} }
if self.index < self.nodes.len() { if self.index < self.nodes.len() {
self.check_update(false);
self.check_for_next_playlist();
let mut is_last = false; let mut is_last = false;
if self.index == self.nodes.len() - 1 { if self.index == self.nodes.len() - 1 {
@ -242,6 +241,10 @@ impl Iterator for CurrentProgram {
self.current_node.next_ad = self.is_ad(self.index, true); self.current_node.next_ad = self.is_ad(self.index, true);
self.index += 1; self.index += 1;
// update playlist should happen after current clip,
// to prevent unknown behaviors.
self.check_update(false);
self.check_for_next_playlist();
Some(self.current_node.clone()) Some(self.current_node.clone())
} else { } else {
let last_playlist = self.json_path.clone(); let last_playlist = self.json_path.clone();