get right playlist on update

This commit is contained in:
jb-alvarado 2022-03-27 18:37:00 +02:00
parent ee096e3b97
commit 25f05c8d63
2 changed files with 11 additions and 3 deletions

View File

@ -28,7 +28,7 @@ pub struct CurrentProgram {
impl CurrentProgram {
pub fn new(rt_handle: Handle, is_terminated: Arc<Mutex<bool>>) -> 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
}

View File

@ -33,7 +33,7 @@ impl Playlist {
}
}
pub fn read_json(rt_handle: Handle, is_terminated: Arc<Mutex<bool>>, seek: bool, next_start: f64) -> Playlist {
pub fn read_json(path: Option<String>, rt_handle: Handle, is_terminated: Arc<Mutex<bool>>, 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<Mutex<bool>>, 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 <b><magenta>{}</></b> not exists!", current_file);