tutorial/progressbin: Handle streams without duration correctly

The "percent-double" field in the message from the progressreport
element only exists if the overall duration of the stream is known.
This commit is contained in:
Sebastian Dröge 2019-12-07 11:03:16 +02:00
parent 0eab103066
commit 486e0e3420

View file

@ -156,11 +156,9 @@ impl BinImpl for ProgressBin {
.unwrap_or(false) =>
{
let s = msg.get_structure().unwrap();
let percent = s
.get_some::<f64>("percent-double")
.expect("ProgressBin::handle_message");
println!("progress: {:5.1}%", percent);
if let Ok(percent) = s.get_some::<f64>("percent-double") {
println!("progress: {:5.1}%", percent);
}
}
_ => self.parent_handle_message(bin, msg),
}