diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index ddab118b9c..bd5886ddca 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -71,11 +71,13 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj) { std::string machine = obj ? obj->dev_id : ""; if (obj && obj->is_function_supported(PrinterFunction::FUNC_CAMERA_VIDEO)) { - m_lan_mode = obj->is_lan_mode_printer(); + m_camera_exists = obj->has_ipcam; + m_lan_mode = obj->is_lan_mode_printer(); m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : ""; - m_lan_passwd = obj->access_code; + m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->access_code : ""; m_tutk_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL); } else { + m_camera_exists = false; m_lan_mode = false; m_lan_ip.clear(); m_lan_passwd.clear(); @@ -102,12 +104,15 @@ void MediaPlayCtrl::Play() return; if (!IsShownOnScreen()) return; + if (m_last_state != MEDIASTATE_IDLE) { + return; + } if (m_machine.empty()) { - Stop(); SetStatus(_L("Initialize failed (No Device)!")); return; } - if (m_last_state != MEDIASTATE_IDLE) { + if (!m_camera_exists) { + SetStatus(_L("Initialize failed (No Camera Device)!")); return; } @@ -135,9 +140,15 @@ void MediaPlayCtrl::Play() return; } - if (m_lan_mode && !m_tutk_support) { // not support tutk - Stop(); - SetStatus(_L("Initialize failed (Not supported)!")); + if (m_lan_mode) { + SetStatus(m_lan_passwd.empty() + ? _L("Initialize failed (Not supported with LAN-only mode)!") + : _L("Initialize failed (Not accessible in LAN-only mode)!")); + return; + } + + if (!m_tutk_support) { // not support tutk + SetStatus(_L("Initialize failed (Not supported without remote video tunnel)!")); return; } @@ -145,14 +156,13 @@ void MediaPlayCtrl::Play() if (agent) { agent->get_camera_url(m_machine, [this, m = m_machine](std::string url) { BOOST_LOG_TRIVIAL(info) << "camera_url: " << url; - if (m != m_machine) return; - CallAfter([this, url] { + CallAfter([this, m, url] { + if (m != m_machine) return; m_url = url; if (m_last_state == MEDIASTATE_INITIALIZING) { - if (url.empty()) { + if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) { Stop(); - m_failed_code = 1; - SetStatus(_L("Initialize failed [%d]!")); + SetStatus(wxString::Format(_L("Initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url))); } else { m_last_state = MEDIASTATE_LOADING; SetStatus(_L("Loading...")); diff --git a/src/slic3r/GUI/MediaPlayCtrl.h b/src/slic3r/GUI/MediaPlayCtrl.h index f8f3945b32..7fb5390a83 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.h +++ b/src/slic3r/GUI/MediaPlayCtrl.h @@ -61,6 +61,7 @@ private: std::string m_lan_ip; std::string m_lan_user; std::string m_lan_passwd; + bool m_camera_exists = false; bool m_lan_mode = false; bool m_tutk_support = false; wxString m_url;