From 25f05c8d6332a1ff110b24922bdc21b276934a19 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Sun, 27 Mar 2022 18:37:00 +0200 Subject: [PATCH] get right playlist on update --- src/input/playlist.rs | 6 +++++- src/utils/json_reader.rs | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/input/playlist.rs b/src/input/playlist.rs index 95aab88d..8fdf3fee 100644 --- a/src/input/playlist.rs +++ b/src/input/playlist.rs @@ -28,7 +28,7 @@ pub struct CurrentProgram { impl CurrentProgram { pub fn new(rt_handle: Handle, is_terminated: Arc>) -> Self { let config = GlobalConfig::global(); - let json = read_json(rt_handle.clone(), is_terminated.clone(), true, 0.0); + let json = read_json(None, rt_handle.clone(), is_terminated.clone(), true, 0.0); Self { config: config.clone(), @@ -47,6 +47,7 @@ impl CurrentProgram { fn check_update(&mut self, seek: bool) { if self.json_path.is_none() { let json = read_json( + None, self.rt_handle.clone(), self.is_terminated.clone(), seek, @@ -66,6 +67,7 @@ impl CurrentProgram { { // when playlist has changed, reload it let json = read_json( + self.json_path.clone(), self.rt_handle.clone(), self.is_terminated.clone(), false, @@ -111,6 +113,7 @@ impl CurrentProgram { || is_close(total_delta, target_length, 2.0) { let json = read_json( + None, self.rt_handle.clone(), self.is_terminated.clone(), false, @@ -426,5 +429,6 @@ fn handle_list_end(mut node: Media, total_delta: f64) -> Media { node.out, node.duration, )); + node } diff --git a/src/utils/json_reader.rs b/src/utils/json_reader.rs index 34f21e14..488a94e3 100644 --- a/src/utils/json_reader.rs +++ b/src/utils/json_reader.rs @@ -33,7 +33,7 @@ impl Playlist { } } -pub fn read_json(rt_handle: Handle, is_terminated: Arc>, seek: bool, next_start: f64) -> Playlist { +pub fn read_json(path: Option, rt_handle: Handle, is_terminated: Arc>, seek: bool, next_start: f64) -> Playlist { let config = GlobalConfig::global(); let mut playlist_path = Path::new(&config.playlist.path).to_owned(); @@ -49,7 +49,11 @@ pub fn read_json(rt_handle: Handle, is_terminated: Arc>, seek: bool, .with_extension("json"); } - let current_file: String = playlist_path.as_path().display().to_string(); + let mut current_file: String = playlist_path.as_path().display().to_string(); + + if let Some(p) = path { + current_file = p + } if !playlist_path.is_file() { error!("Playlist {} not exists!", current_file);