FIX: stop video when not visible

Change-Id: Ibc5204084efec5381a7ede9face0519276592aa8
This commit is contained in:
chunmao.guo 2022-08-31 17:15:34 +08:00 committed by Lane.Wei
parent 08c9385383
commit 4601022aaa
3 changed files with 15 additions and 3 deletions

View file

@ -40,6 +40,14 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
#if BBL_RELEASE_TO_PUBLIC
m_next_retry = wxDateTime::Now();
#endif
auto onShowHide = [this](auto &e) {
e.Skip();
if (m_isBeingDeleted) return;
IsShownOnScreen() ? Play() : Stop();
};
parent->Bind(wxEVT_SHOW, onShowHide);
parent->GetParent()->GetParent()->Bind(wxEVT_SHOW, onShowHide);
}
MediaPlayCtrl::~MediaPlayCtrl()
@ -72,6 +80,10 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
void MediaPlayCtrl::Play()
{
if (!m_next_retry.IsValid())
return;
if (!IsShownOnScreen())
return;
if (m_machine.empty()) {
Stop();
SetStatus(_L("Initialize failed (No Device)!"));