move sanity check, again

This commit is contained in:
Erica Z 2024-11-05 10:22:50 +01:00
parent 5e62838371
commit fec04928b8

View file

@ -71,6 +71,7 @@ mod imp {
mpv.observe_property(5, "time-pos").unwrap(); mpv.observe_property(5, "time-pos").unwrap();
mpv.observe_property(6, "playlist-count").unwrap(); mpv.observe_property(6, "playlist-count").unwrap();
mpv.observe_property(7, "duration").unwrap(); mpv.observe_property(7, "duration").unwrap();
mpv.observe_property(8, "path").unwrap();
// "Useful to drain property changes before a new file is loaded." // "Useful to drain property changes before a new file is loaded."
mpv.add_hook(0, "on_before_start_file", 0).unwrap(); mpv.add_hook(0, "on_before_start_file", 0).unwrap();
@ -171,6 +172,18 @@ mod imp {
window.notify("duration"); window.notify("duration");
} }
8 => {
assert_eq!(event.name, "path");
// sanity check
match window.imp().mpv.get_property::<String>("path") {
Ok(path) => {
assert_eq!(path, window.song().unwrap().stream_url())
}
Err(err) if err.is_property_unavailable() => {}
Err(err) => Err(err).unwrap(),
}
}
_ => unreachable!(), _ => unreachable!(),
}, },
@ -402,16 +415,6 @@ mod imp {
.dynamic_cast() .dynamic_cast()
.unwrap(); .unwrap();
// sanity check
match self.mpv.get_property::<String>("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) Some(song)
} }
} }