ENH: stop liveview long time no input
Change-Id: I0951e2f4e8ff9433a66b15bb852d4d5c1d0974d5 Jira: STUDIO-7574 (cherry picked from commit 81ca78382f8adba58bbb72bc7810ef76f746fbd6)
This commit is contained in:
parent
0d1cc0a5c5
commit
e3a7ad0548
|
@ -21,6 +21,9 @@
|
|||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
#include <wx/clipbrd.h>
|
||||
#include "wx/evtloop.h"
|
||||
|
@ -37,6 +40,8 @@ static std::map<int, std::string> error_messages = {
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
static int SecondsSinceLastInput();
|
||||
|
||||
MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const wxPoint &pos, const wxSize &size)
|
||||
: wxPanel(parent, wxID_ANY, pos, size)
|
||||
, m_media_ctrl(media_ctrl)
|
||||
|
@ -178,6 +183,10 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
|||
agent->get_camera_url(machine, [](auto) {});
|
||||
m_last_user_play = wxDateTime::Now();
|
||||
}
|
||||
if (m_last_state == wxMediaState::wxMEDIASTATE_PLAYING && SecondsSinceLastInput() > 900) { // 15 minutes
|
||||
m_next_retry = wxDateTime();
|
||||
Stop(_L("Temporarily closed because there is no operating for a long time."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
m_machine = machine;
|
||||
|
@ -303,7 +312,8 @@ void MediaPlayCtrl::Play()
|
|||
m_disable_lan = false;
|
||||
m_failed_code = 0;
|
||||
m_last_state = MEDIASTATE_INITIALIZING;
|
||||
|
||||
m_button_play->SetIcon("media_stop");
|
||||
|
||||
if (!m_remote_support) { // not support tutk
|
||||
m_failed_code = -1;
|
||||
m_url = "bambu:///local/";
|
||||
|
@ -849,6 +859,20 @@ bool MediaPlayCtrl::get_stream_url(std::string *url)
|
|||
return url == nullptr;
|
||||
}
|
||||
|
||||
static int SecondsSinceLastInput()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LASTINPUTINFO lii;
|
||||
lii.cbSize = sizeof(lii);
|
||||
::GetLastInputInfo(&lii);
|
||||
return (::GetTickCount() - lii.dwTime) / 1000;
|
||||
#elif defined(__APPLE__)
|
||||
return (int)CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateHIDSystemState, kCGAnyInputEventType);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
void wxMediaCtrl2::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
|
Loading…
Reference in New Issue