From 466af9f1b37033b2c9cb20081745dc0c608cecdb Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 21 Feb 2022 19:33:39 -0500 Subject: [PATCH] Stop iterating if the reason a video stopped is anything except eof. --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index 3bb8223..f501901 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,17 @@ async fn main() -> Result<(), Box> { mpvctl.play_video(f.path()).await?; if let Some(evt) = end_file_listener.recv().await { println!("end file event {}", evt); + if let serde_json::Value::Object(obj) = evt { + let reason = obj.get("reason"); + if let Some(serde_json::Value::String(reason_body)) = reason { + if reason_body == "eof" { + // Watched the video until the end + continue; + } + } + } } + break; } println!("done {}", client_name);