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) } }