From 0e0718e45d928f6a5596705b67dbb36223e26451 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 14 Aug 2025 20:31:47 -0600 Subject: [PATCH] Handle codec install during file open, fixes #23 --- src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 76feab8..0bdaa63 100644 --- a/src/main.rs +++ b/src/main.rs @@ -374,8 +374,29 @@ impl App { Ok(ok) => ok, Err(err) => { log::warn!("failed to open {}: {err}", url); + // Handle codecs required before the file can play + let mut commands = Vec::new(); + while let Some(msg) = pipeline + .bus() + .unwrap() + .pop_filtered(&[gst::MessageType::Element]) + { + match msg.view() { + gst::MessageView::Element(element) => { + if gst_pbutils::MissingPluginMessage::is(&element) { + commands.push(Command::perform( + async { message::app(Message::MissingPlugin(msg)) }, + |x| x, + )); + // Do one codec install at a time + break; + } + } + _ => {} + } + } pipeline.set_state(gst::State::Null).unwrap(); - return Command::none(); + return Command::batch(commands); } } };