#include "stdafx.h"
#include "demo_player_control_widget.h"
#include "demo_player_control_view.h"
ADTF_PLUGIN(
"Demo Qt5 Player Control View Plugin", cPlayerControlViewSrv);
#ifdef GetObject
#undef GetObject
#endif
#ifdef GetCurrentTime
#undef GetCurrentTime
#endif
void show_result(QWidget* pWidget,
tResult nRes)
{
QMessageBox::critical(pWidget,
}
{
{
show_result(pWidget, nRes);
}
return nRes;
}
cPlayerControlViewSrv::cPlayerControlViewSrv()
{
m_strTitle =
cString(
"Demo Player Control");
m_pWidget = nullptr;
SetDescription("Use this UI Service to extend the ADTF System with a User Interface to control the ADTFDAT File Player.");
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_player_control_view.html");
}
QWidget* cPlayerControlViewSrv::CreateView()
{
m_pWidget = new cPlayerControlWidget(nullptr, *this);
return m_pWidget;
}
void cPlayerControlViewSrv::ReleaseView()
{
delete m_pWidget;
m_pWidget = nullptr;
}
tResult cPlayerControlViewSrv::OnIdle()
{
if (cHighResTimer::GetTime() - m_tmLastUpdate < m_tmMinInterval)
{
}
if (m_pWidget)
{
cPlayerControlWidget::tPlayerInfo sInfo;
if (m_pPlayer)
{
sInfo.bPlayerPresent = true;
sInfo.eState = m_pPlayer->GetCurrentState();
m_pPlayer->GetTimeRange(sInfo.tmBegin, sInfo.tmEnd);
sInfo.tmCurrent = m_pPlayer->GetCurrentTime();
}
m_pWidget->Update(sInfo);
}
m_tmLastUpdate = cHighResTimer::GetTime();
}
tResult cPlayerControlViewSrv::ServiceEvent(
int nEventId,
uint32_t ui32Param1,
uint32_t ui32Param2,
void* pvData,
int szData)
{
if (nEventId == IService::SE_ChangeRunLevel)
{
if (ui32Param2 == IRuntime::CRLF_PostIncrementLevel ||
ui32Param2 == IRuntime::CRLF_PostDecrementLevel)
{
}
else if (ui32Param2 == IRuntime::CRLF_PreDecrementLevel)
{
if (eLevel == tADTFRunLevel::RL_Running)
{
Pause();
}
}
}
return cQtUIService::ServiceEvent(nEventId, ui32Param1, ui32Param2, pvData, szData);
}
void cPlayerControlViewSrv::OpenFile(const QString& strFile)
{
if (m_pPlayer)
{
if (m_pPlayer)
{
tResult nRes = m_pPlayer->Open(
static_cast<const char*
>(strFile.toUtf8()),
true);
{
show_result(m_pWidget, nRes);
}
else
{
local_set_run_level(m_pWidget, eOldLevel);
}
}
}
}
void cPlayerControlViewSrv::Run()
{
local_set_run_level(m_pWidget, tADTFRunLevel::RL_Running);
}
void cPlayerControlViewSrv::Pause()
{
if (m_pPlayer)
{
m_pPlayer->Pause();
}
}
void cPlayerControlViewSrv::Play()
{
if (m_pPlayer)
{
m_pPlayer->Play();
}
}
void cPlayerControlViewSrv::Stop()
{
}
void cPlayerControlViewSrv::SeekToTime(
tTimeStamp tmTime)
{
if (m_pPlayer)
{
m_pPlayer->SeekToTime(tmTime);
}
}
#define ADTF_PLUGIN(__plugin_identifier,...)
The ADTF Plugin Macro will add the code of a adtf::ucom::ant::IPlugin implementation.
#define IS_FAILED(s)
Check if result is failed.
#define LOG_RESULT(code)
Log result to console.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_IF_POINTER_NULL(_ptr)
Return ERR_POINTER if _ptr is nullptr, which requires the calling function's return type to be tResul...
const tChar * GetDescription() const
Get user provided error description.
const tChar * GetErrorString() const
Get error code as string representation.
tErrorCode GetErrorCode() const
Get error code.
virtual tResult SetRunLevel(int8_t nRunLevel, bool bWait=true)=0
Set run level.
virtual tResult GetObject(iobject_ptr< IObject > &pObject, const char *strNameOID) const =0
Get registered object from object registry.
virtual int8_t GetRunLevel() const =0
Get current run level.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
tADTFRunLevel
The ADTF Runtime Level State are used to define a ADTF Runtime specialization for a adtf::ucom::ant::...
@ RL_Session
The session level.
@ RL_FilterGraph
The Filtergraph level.
adtf::ucom::IRuntime * _runtime
Global Runtime Pointer to reference to the current runtime.
#define adtf_string_intf(__string__)
The adtf_string_intf Macro helps to easily create a rvalue reference of a adtf::util::cString.
error_code_type value
Value of this error code.