const VideoStreamInfo* pInfo = null;
MediaStreamInfo* pStreamInfo = null;
- if (__pPlayer->GetState() == PLAYER_STATE_PLAYING)
+ if (GetState() == PLAYER_STATE_PLAYING)
{
pStreamInfo = __pPlayer->GetCurrentMediaStreamInfoN();
if (pStreamInfo == null)
AppLogDebug("__pPlayer [%x]", __pPlayer);
r = __pPlayer->Construct(*this, &bufferInfo);
- if (IsFailed(r))
- {
- delete __pPlayer;
- __pPlayer = null;
- }
+ TryCatch(r == E_SUCCESS, , "__pPlayer->Construct failed:%s", GetErrorMessage(r));
return r;
CATCH:
+ delete __pPlayer;
+ __pPlayer = null;
return r;
}
{
result r = E_FAILURE;
- PlayerState playState = __pPlayer->GetState();
+ PlayerState playState = GetState();
+
+ TryCatch(__pPlayer != null, ,"__pPlayer is null");
switch (playState)
{
VideoPlayerPresentationModel::SetPlayerBuffer(const BufferInfo& bufferInfo)
{
result r = E_FAILURE;
+ TryReturnVoid(__pPlayer != null, "__pPlayer is null");
r = __pPlayer->SetRenderingBuffer(bufferInfo);
TryReturnVoid(r == E_SUCCESS, "__pPlayer->SetRenderingBuffer failed:%s", GetErrorMessage(r));
}
String mediaName;
String delim = L"/";
- PlayerState playState = __pPlayer->GetState();
+ PlayerState playState = GetState();
AppLogDebug("StartPlay : %d", playState);
+ TryCatch(__pPlayer != null, ,"__pPlayer is null");
+
switch (playState)
{
case PLAYER_STATE_INITIALIZED:
break;
}
- CallOnPlayStateChanged(__pPlayer->GetState());
+ CallOnPlayStateChanged(GetState());
CATCH:
return r;
__stateAfterSeek = PLAYER_STATE_PAUSED;
}
- CallOnPlayStateChanged(__pPlayer->GetState());
+ CallOnPlayStateChanged(GetState());
CATCH:
return r;
PlayerState
VideoPlayerPresentationModel::GetState(void) const
{
+ TryReturn(__pPlayer != null, PLAYER_STATE_ERROR, "__pPlayer is null");
+
return __pPlayer->GetState();
}
long
VideoPlayerPresentationModel::GetDuration(void) const
{
+ TryReturn(__pPlayer != null, 0, "__pPlayer is null");
+
return __pPlayer->GetDuration();
}
long
VideoPlayerPresentationModel::GetPosition(void) const
{
+ TryReturn(__pPlayer != null, 0, "__pPlayer is null");
+
return __pPlayer->GetPosition();
}
AppLogDebug("OnPlayerInterrupted");
__pVideoPlayerEventListener->OnPlayInterrupted();
- CallOnPlayStateChanged(__pPlayer->GetState());
+ CallOnPlayStateChanged(GetState());
}
void
{
AppLogDebug("OnPlayerAudioFocusChanged");
- CallOnPlayStateChanged(__pPlayer->GetState());
+ CallOnPlayStateChanged(GetState());
}
void
String currentPlayTime;
long playerDuration = 0;
+ PlayerState playState = GetState();
+
if (timer.GetHashCode() == __pTimer->GetHashCode())
{
- if (__pPlayer->GetState() == PLAYER_STATE_INITIALIZED || __pPlayer->GetState() == PLAYER_STATE_PLAYING)
+ if (playState == PLAYER_STATE_INITIALIZED || playState == PLAYER_STATE_PLAYING)
{
- playerDuration = __pPlayer->GetDuration();
- dateTime.AddSeconds(__pPlayer->GetPosition() / MILLISECOND);
+ playerDuration = GetDuration();
+ dateTime.AddSeconds(GetPosition() / MILLISECOND);
currentPlayTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
}
else if (timer.GetHashCode() == __pFastForwardTimer->GetHashCode())
{
- msTime = __pPlayer->GetPosition();
- playerDuration = __pPlayer->GetDuration();
+ msTime = GetPosition();
+ playerDuration = GetDuration();
msTime = msTime + (TWO_SEC * MILLISECOND);
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
}
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
}
}
else if (timer.GetHashCode() == __pFastRewindTimer->GetHashCode())
{
- msTime = __pPlayer->GetPosition();
- playerDuration = __pPlayer->GetDuration();
+ msTime = GetPosition();
+ playerDuration = GetDuration();
msTime = msTime - (TWO_SEC * MILLISECOND);
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
}
AppLogDebug("Forward");
- PlayerState playState = __pPlayer->GetState();
+ PlayerState playState = GetState();
if (playState != PLAYER_STATE_ENDOFCLIP)
{
- playerDuration = __pPlayer->GetDuration();
- msTime = __pPlayer->GetPosition();
+ playerDuration = GetDuration();
+ msTime = GetPosition();
- if (msTime > START_TIME)
+ if (!(msTime == START_TIME && playState == PLAYER_STATE_PLAYING ))
{
msTime = msTime + (TEN_SEC * MILLISECOND);
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
AppLogDebug("Rewind");
- PlayerState playState = __pPlayer->GetState();
+ PlayerState playState = GetState();
if (playState != PLAYER_STATE_ENDOFCLIP)
{
- playerDuration = __pPlayer->GetDuration();
- msTime = __pPlayer->GetPosition();
+ playerDuration = GetDuration();
+ msTime = GetPosition();
msTime = msTime - (TEN_SEC * MILLISECOND);
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
if (playerDuration != START_TIME)
{
- currentProgressPos = static_cast<int>(__pPlayer->GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
+ currentProgressPos = static_cast<int>(GetPosition() / (playerDuration / MAX_PROGRESS_RANGE));
}
CallOnPlayTimeChanged(currentProgressPos, currentPlayTime);
{
AppLogDebug("FastForward");
- if (__pPlayer->GetState() != PLAYER_STATE_ENDOFCLIP)
+ if (GetState() != PLAYER_STATE_ENDOFCLIP)
{
PausePlay();
if(playAfterSeek)
{
AppLogDebug("FastRewind");
- if (__pPlayer->GetState() != PLAYER_STATE_ENDOFCLIP)
+ if (GetState() != PLAYER_STATE_ENDOFCLIP)
{
PausePlay();
if(playAfterSeek)
{
AppLogDebug("StopFastForwardRewind");
- if (__pPlayer->GetState() != PLAYER_STATE_ENDOFCLIP)
+ if (GetState() != PLAYER_STATE_ENDOFCLIP)
{
__pFastForwardTimer->Cancel();
__pFastRewindTimer->Cancel();
{
if (__stateAfterSeek == PLAYER_STATE_PLAYING)
{
- result r = __pPlayer->Play();
+ result r = StartPlay();
TryReturnVoid(r == E_SUCCESS, "__pPlayer->Play() failed:%s", GetErrorMessage(r));
- CallOnPlayStateChanged(__pPlayer->GetState());
+ CallOnPlayStateChanged(GetState());
__pTimer->Start(PROGRESS_TIMER_DURATION);
}
AppLogDebug("__pPlayer [%x]", __pPlayer);
r = __pPlayer->Construct(*this, &bufferInfo);
- if (IsFailed(r))
- {
- delete __pPlayer;
- __pPlayer = null;
- }
+ TryCatch(r == E_SUCCESS, , "__pPlayer->Construct failed:%s", GetErrorMessage(r));
return r;
CATCH:
+ delete __pPlayer;
+ __pPlayer = null;
return r;
}
{
AppLogDebug("ChangeCurrentMediaIndex");
- if (__pPlayer->GetState() == PLAYER_STATE_ENDOFCLIP)
+ if (GetState() == PLAYER_STATE_ENDOFCLIP)
{
switch (GetRepeatMode())
{