FIX: Media playing state & detect play end

Change-Id: I378da3f104120110b8032a355a22a89ebe69a0fb
This commit is contained in:
chunmao.guo 2022-10-17 09:55:18 +08:00 committed by Lane.Wei
parent 746d5960ba
commit 84a4622fdf

View file

@ -193,6 +193,9 @@ void MediaPlayCtrl::Stop()
m_tasks.push_back("<stop>"); m_tasks.push_back("<stop>");
m_cond.notify_all(); m_cond.notify_all();
m_last_state = MEDIASTATE_IDLE; m_last_state = MEDIASTATE_IDLE;
if (m_failed_code)
SetStatus(_L("Stopped [%d]!"), true);
else
SetStatus(_L("Stopped."), false); SetStatus(_L("Stopped."), false);
if (m_failed_code >= 100) // not keep retry on local error if (m_failed_code >= 100) // not keep retry on local error
m_next_retry = wxDateTime(); m_next_retry = wxDateTime();
@ -286,6 +289,7 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent& event)
} }
if ((last_state == wxMEDIASTATE_PAUSED || last_state == wxMEDIASTATE_PLAYING) && if ((last_state == wxMEDIASTATE_PAUSED || last_state == wxMEDIASTATE_PLAYING) &&
state == wxMEDIASTATE_STOPPED) { state == wxMEDIASTATE_STOPPED) {
m_failed_code = m_media_ctrl->GetLastError();
Stop(); Stop();
return; return;
} }
@ -306,9 +310,9 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent& event)
if (m_failed_code == 0) if (m_failed_code == 0)
m_failed_code = 2; m_failed_code = 2;
SetStatus(_L("Load failed [%d]!")); SetStatus(_L("Load failed [%d]!"));
} else {
m_last_state = last_state;
} }
} else {
m_last_state = state;
} }
} }