FIX: stop video when not visible
Change-Id: Ibc5204084efec5381a7ede9face0519276592aa8
This commit is contained in:
parent
08c9385383
commit
4601022aaa
3 changed files with 15 additions and 3 deletions
|
@ -146,9 +146,10 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
|||
m_button_delete->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &e) { m_image_grid->DoActionOnSelection(0); });
|
||||
|
||||
auto onShowHide = [this](auto &e) {
|
||||
e.Skip();
|
||||
if (m_isBeingDeleted) return;
|
||||
auto fs = m_image_grid ? m_image_grid->GetFileSystem() : nullptr;
|
||||
if (fs) e.IsShown() && IsShown() ? fs->Start() : fs->Stop();
|
||||
if (fs) IsShownOnScreen() ? fs->Start() : fs->Stop();
|
||||
};
|
||||
Bind(wxEVT_SHOW, onShowHide);
|
||||
parent->GetParent()->Bind(wxEVT_SHOW, onShowHide);
|
||||
|
|
|
@ -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)!"));
|
||||
|
|
|
@ -402,7 +402,7 @@ void MonitorPanel::update_all()
|
|||
m_upgrade_panel->update(obj);
|
||||
|
||||
|
||||
m_status_info_panel->m_media_play_ctrl->SetMachineObject(IsShown() ? obj : nullptr);
|
||||
m_status_info_panel->m_media_play_ctrl->SetMachineObject(obj);
|
||||
m_media_file_panel->SetMachineObject(obj);
|
||||
update_status(obj);
|
||||
|
||||
|
@ -466,7 +466,6 @@ bool MonitorPanel::Show(bool show)
|
|||
}
|
||||
} else {
|
||||
m_refresh_timer->Stop();
|
||||
m_status_info_panel->m_media_play_ctrl->SetMachineObject(nullptr);
|
||||
}
|
||||
return wxPanel::Show(show);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue