get right playlist on update
This commit is contained in:
parent
ee096e3b97
commit
25f05c8d63
@ -28,7 +28,7 @@ pub struct CurrentProgram {
|
|||||||
impl CurrentProgram {
|
impl CurrentProgram {
|
||||||
pub fn new(rt_handle: Handle, is_terminated: Arc<Mutex<bool>>) -> Self {
|
pub fn new(rt_handle: Handle, is_terminated: Arc<Mutex<bool>>) -> Self {
|
||||||
let config = GlobalConfig::global();
|
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 {
|
Self {
|
||||||
config: config.clone(),
|
config: config.clone(),
|
||||||
@ -47,6 +47,7 @@ impl CurrentProgram {
|
|||||||
fn check_update(&mut self, seek: bool) {
|
fn check_update(&mut self, seek: bool) {
|
||||||
if self.json_path.is_none() {
|
if self.json_path.is_none() {
|
||||||
let json = read_json(
|
let json = read_json(
|
||||||
|
None,
|
||||||
self.rt_handle.clone(),
|
self.rt_handle.clone(),
|
||||||
self.is_terminated.clone(),
|
self.is_terminated.clone(),
|
||||||
seek,
|
seek,
|
||||||
@ -66,6 +67,7 @@ impl CurrentProgram {
|
|||||||
{
|
{
|
||||||
// when playlist has changed, reload it
|
// when playlist has changed, reload it
|
||||||
let json = read_json(
|
let json = read_json(
|
||||||
|
self.json_path.clone(),
|
||||||
self.rt_handle.clone(),
|
self.rt_handle.clone(),
|
||||||
self.is_terminated.clone(),
|
self.is_terminated.clone(),
|
||||||
false,
|
false,
|
||||||
@ -111,6 +113,7 @@ impl CurrentProgram {
|
|||||||
|| is_close(total_delta, target_length, 2.0)
|
|| is_close(total_delta, target_length, 2.0)
|
||||||
{
|
{
|
||||||
let json = read_json(
|
let json = read_json(
|
||||||
|
None,
|
||||||
self.rt_handle.clone(),
|
self.rt_handle.clone(),
|
||||||
self.is_terminated.clone(),
|
self.is_terminated.clone(),
|
||||||
false,
|
false,
|
||||||
@ -426,5 +429,6 @@ fn handle_list_end(mut node: Media, total_delta: f64) -> Media {
|
|||||||
node.out,
|
node.out,
|
||||||
node.duration,
|
node.duration,
|
||||||
));
|
));
|
||||||
|
|
||||||
node
|
node
|
||||||
}
|
}
|
||||||
|
@ -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 config = GlobalConfig::global();
|
||||||
|
|
||||||
let mut playlist_path = Path::new(&config.playlist.path).to_owned();
|
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");
|
.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() {
|
if !playlist_path.is_file() {
|
||||||
error!("Playlist <b><magenta>{}</></b> not exists!", current_file);
|
error!("Playlist <b><magenta>{}</></b> not exists!", current_file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user