fix reset status on new day, better error messsages for rpc

This commit is contained in:
jb-alvarado 2022-04-08 15:13:42 +02:00
parent a8541ead64
commit 7bcd344d6d
2 changed files with 17 additions and 9 deletions

View File

@ -157,6 +157,7 @@ impl CurrentProgram {
});
*self.playout_stat.current_date.lock().unwrap() = json.date.clone();
*self.playout_stat.time_shift.lock().unwrap() = 0.0;
let status_data: String =
serde_json::to_string(&data).expect("Serialize status data failed");
fs::write(self.config.general.stat_file.clone(), &status_data)

View File

@ -75,11 +75,12 @@ pub async fn json_rpc_server(
let mut date = playout_stat.date.lock().unwrap();
if map.contains_key("control") && &map["control"] == "next" {
if let Ok(_) = kill_decoder(proc.decoder_term.clone()) {
info!("Move to next clip");
let index = *play.index.lock().unwrap();
let index = *play.index.lock().unwrap();
if index < play.current_list.lock().unwrap().len() {
if let Ok(_) = kill_decoder(proc.decoder_term.clone()) {
info!("Move to next clip");
if index < play.current_list.lock().unwrap().len() {
let mut data_map = Map::new();
let mut media = play.current_list.lock().unwrap()[index].clone();
media.add_probe();
@ -95,15 +96,18 @@ pub async fn json_rpc_server(
return Ok(Value::Object(data_map));
}
return Ok(Value::String("Move failed".to_string()));
}
return Ok(Value::String("Move failed".to_string()));
return Ok(Value::String("Last clip can not be skipped".to_string()));
}
if map.contains_key("control") && &map["control"] == "back" {
if let Ok(_) = kill_decoder(proc.decoder_term.clone()) {
let index = *play.index.lock().unwrap();
let index = *play.index.lock().unwrap();
if index > 1 && play.current_list.lock().unwrap().len() > 1 {
if index > 1 && play.current_list.lock().unwrap().len() > 1 {
if let Ok(_) = kill_decoder(proc.decoder_term.clone()) {
info!("Move to last clip");
let mut data_map = Map::new();
let mut media = play.current_list.lock().unwrap()[index - 2].clone();
@ -121,8 +125,11 @@ pub async fn json_rpc_server(
return Ok(Value::Object(data_map));
}
return Ok(Value::String("Move failed".to_string()));
}
return Ok(Value::String("Move failed".to_string()));
return Ok(Value::String("Clip index out of range".to_string()));
}
if map.contains_key("control") && &map["control"] == "reset" {