From 730aa890c324426d6954afd9cb6333f1148288c5 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Wed, 11 Jan 2023 17:52:48 -0500 Subject: [PATCH] wxMediaCtrl2: provide a better error message if the system does not have h.264 codecs installed --- src/slic3r/GUI/wxMediaCtrl2.cpp | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/slic3r/GUI/wxMediaCtrl2.cpp b/src/slic3r/GUI/wxMediaCtrl2.cpp index dde69727f..550d67e45 100644 --- a/src/slic3r/GUI/wxMediaCtrl2.cpp +++ b/src/slic3r/GUI/wxMediaCtrl2.cpp @@ -102,6 +102,42 @@ void wxMediaCtrl2::Load(wxURI url) } url = wxURI(url.BuildURI().append("&hwnd=").append( boost::lexical_cast(GetHandle()))); +#endif +#ifdef __WXGTK3__ + GstElementFactory *factory; + int hasplugins = 1; + + factory = gst_element_factory_find("h264parse"); + if (!factory) { + hasplugins = 0; + } else { + gst_object_unref(factory); + } + + factory = gst_element_factory_find("openh264dec"); + if (!factory) { + factory = gst_element_factory_find("avdec_h264"); + } + if (!factory) { + factory = gst_element_factory_find("vaapih264dec"); + } + if (!factory) { + hasplugins = 0; + } else { + gst_object_unref(factory); + } + + if (!hasplugins) { + Slic3r::GUI::wxGetApp().CallAfter([] { + wxMessageBox(_L("Your system is missing H.264 codecs for GStreamer, which are required to play video. (Try installing the gstreamer1.0-plugins-bad or gstreamer1.0-libav packages, then restart Bambu Studio?)"), _L("Error"), wxOK); + }); + m_error = 101; + wxMediaEvent event(wxEVT_MEDIA_STATECHANGED); + event.SetId(GetId()); + event.SetEventObject(this); + wxPostEvent(this, event); + return; + } #endif m_error = 0; wxMediaCtrl::Load(url);