From fec04928b8f68a3845f3b84351c08d959520c58b Mon Sep 17 00:00:00 2001 From: Erica Z Date: Tue, 5 Nov 2024 10:22:50 +0100 Subject: [PATCH] move sanity check, again --- src/ui/window.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ui/window.rs b/src/ui/window.rs index abe5286..590ebc4 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -71,6 +71,7 @@ mod imp { mpv.observe_property(5, "time-pos").unwrap(); mpv.observe_property(6, "playlist-count").unwrap(); mpv.observe_property(7, "duration").unwrap(); + mpv.observe_property(8, "path").unwrap(); // "Useful to drain property changes before a new file is loaded." mpv.add_hook(0, "on_before_start_file", 0).unwrap(); @@ -171,6 +172,18 @@ mod imp { window.notify("duration"); } + 8 => { + assert_eq!(event.name, "path"); + // sanity check + match window.imp().mpv.get_property::("path") { + Ok(path) => { + assert_eq!(path, window.song().unwrap().stream_url()) + } + Err(err) if err.is_property_unavailable() => {} + Err(err) => Err(err).unwrap(), + } + } + _ => unreachable!(), }, @@ -402,16 +415,6 @@ mod imp { .dynamic_cast() .unwrap(); - // sanity check - match self.mpv.get_property::("path") { - Ok(path) => assert_eq!(song.stream_url(), path), - Err(err) if err.is_property_unavailable() => { - // NOTE: this happens between EndFile and StartFile - event!(Level::WARN, "can't do sanity check, path is unavailable") - } - Err(err) => Err(err).unwrap(), - }; - Some(song) } }