FIX: not play liveview when device is busy downloading

Change-Id: I48dc1c28fc78d69bfd37d1b531aa7daf5e6e4cbd
This commit is contained in:
chunmao.guo 2023-01-18 15:00:09 +08:00 committed by Lane.Wei
parent faa918d872
commit bea48a08d6
3 changed files with 14 additions and 5 deletions

View file

@ -87,15 +87,17 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : "";
m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->get_access_code() : "";
m_tutk_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL);
m_device_busy = obj->is_in_prepare();
} else {
m_camera_exists = false;
m_lan_mode = false;
m_lan_ip.clear();
m_lan_passwd.clear();
m_tutk_support = true;
m_device_busy = false;
}
if (machine == m_machine) {
if (m_last_state == MEDIASTATE_IDLE && m_next_retry.IsValid() && wxDateTime::Now() >= m_next_retry)
if (m_last_state == MEDIASTATE_IDLE)
Play();
return;
}
@ -118,7 +120,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
void MediaPlayCtrl::Play()
{
if (!m_next_retry.IsValid())
if (!m_next_retry.IsValid() || wxDateTime::Now() < m_next_retry)
return;
if (!IsShownOnScreen())
return;
@ -141,7 +143,7 @@ void MediaPlayCtrl::Play()
NetworkAgent *agent = wxGetApp().getAgent();
std::string agent_version = agent ? agent->get_version() : "";
if (!m_lan_ip.empty() && (!m_lan_mode || !m_lan_passwd.empty())) {
if (!m_lan_ip.empty() && (!m_lan_mode || !m_lan_passwd.empty()) && !m_device_busy) {
m_url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd + "&device=" + m_machine + "&version=" + agent_version;
m_last_state = MEDIASTATE_LOADING;
SetStatus(_L("Loading..."));
@ -170,6 +172,11 @@ void MediaPlayCtrl::Play()
}
if (!m_tutk_support) { // not support tutk
if (m_device_busy) {
Stop(_L("Printer is busy downloading, Please wait for the downloading to finish."));
m_failed_retry = 0;
return;
}
m_failed_code = 1;
Stop(m_lan_ip.empty()
? _L("Initialize failed (Missing LAN ip of printer)!")
@ -231,7 +238,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
SetStatus(msg, false);
}
++m_failed_retry;
if (m_failed_code != 0 && !m_tutk_support) {
if (m_failed_code != 0 && !m_tutk_support && m_failed_retry > 1) {
m_next_retry = wxDateTime(); // stop retry
if (wxGetApp().show_modal_ip_address_enter_dialog(_L("LAN Connection Failed (Failed to start liveview)"))) {
m_failed_retry = 0;
@ -403,6 +410,7 @@ void MediaPlayCtrl::on_show_hide(wxShowEvent &evt)
{
evt.Skip();
if (m_isBeingDeleted) return;
m_failed_retry = 0;
IsShownOnScreen() ? Play() : Stop();
}

View file

@ -74,6 +74,7 @@ private:
bool m_camera_exists = false;
bool m_lan_mode = false;
bool m_tutk_support = false;
bool m_device_busy = false;
wxString m_url;
std::deque<wxString> m_tasks;

View file

@ -83,7 +83,7 @@ void wxMediaCtrl2::Load(wxURI url)
wxMessageBox(_L("Missing BambuSource component registered for media playing! Please re-install BambuStutio or seek after-sales help."), _L("Error"), wxOK);
});
}
m_error = clsid != L"{233E64FB-2041-4A6C-AFAB-FF9BCF83E7AA}" ? 101 : path.empty() ? 102 : 103;
m_error = clsid != CLSID_BAMBU_SOURCE ? 101 : path.empty() ? 102 : 103;
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
event.SetId(GetId());
event.SetEventObject(this);