TDIS-6497, N_SE-45491, Back event changes
authorAbhismita Ghosh <g.abhismita@samsung.com>
Tue, 9 Jul 2013 09:58:47 +0000 (18:58 +0900)
committerAbhismita Ghosh <g.abhismita@samsung.com>
Wed, 10 Jul 2013 07:46:54 +0000 (16:46 +0900)
Change-Id: I793dccf9369255f3e145b873e71111aa766ce387

src/VpVideoPlayerForm.cpp
src/VpVideoPlayerPresentationModel.cpp [changed mode: 0755->0644]

index 2015f54..35d849f 100644 (file)
@@ -343,7 +343,6 @@ VideoPlayerForm::OnInitializing(void)
        __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
 
        r = __pVideoPlayerPresentationModel->InitializePlayer();
-       TryCatch(r == E_SUCCESS, , "InitializePlayer() failed : %s", GetErrorMessage(r));
 
        __pVideoPlayerPresentationModel->SetVideoPlayerEventListener(this);
 
@@ -1739,11 +1738,16 @@ VideoPlayerForm::OnFormBackRequested(Form& source)
 {
        AppLogDebug("OnFormBackRequested");
 
-       UiApp* pApp = UiApp::GetInstance();
-       TryReturnVoid(pApp != null, "pApp is null");
+       bool frameActivated = GetFrameActivated();
 
-       result r = pApp->Terminate();
-       TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
+       if (frameActivated == true)
+       {
+               UiApp* pApp = UiApp::GetInstance();
+               TryReturnVoid(pApp != null, "pApp is null");
+
+               result r = pApp->Terminate();
+               TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
+       }
 }
 
 void
@@ -2208,10 +2212,10 @@ VideoPlayerForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
                        Battery::GetCurrentLevel(batteryLevel);
                        Battery::IsCharging(isCharging);
 
-                       bool frameActivated = GetFrameActivated();
-
                        if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
                        {
+                               bool frameActivated = GetFrameActivated();
+
                                if (isCharging == false && frameActivated == true)
                                {
                                        OnFormBackRequested(*this);
old mode 100755 (executable)
new mode 100644 (file)
index c42414a..9d7c3c4
@@ -153,7 +153,7 @@ VideoPlayerPresentationModel::GetVideoInfoN(const String& mediaLocalPath)
        const VideoStreamInfo* pInfo = null;
        MediaStreamInfo* pStreamInfo = null;
 
-       if (__pPlayer->GetState() == PLAYER_STATE_PLAYING)
+       if (GetState() == PLAYER_STATE_PLAYING)
        {
                pStreamInfo = __pPlayer->GetCurrentMediaStreamInfoN();
                if (pStreamInfo == null)
@@ -214,15 +214,13 @@ VideoPlayerPresentationModel::ConstructPlayerInstanceWithBufferInfo(void)
        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;
 }
 
@@ -231,7 +229,9 @@ VideoPlayerPresentationModel::SeekTo(long msTime)
 {
        result r = E_FAILURE;
 
-       PlayerState playState = __pPlayer->GetState();
+       PlayerState playState = GetState();
+
+       TryCatch(__pPlayer != null, ,"__pPlayer is null");
 
        switch (playState)
        {
@@ -286,6 +286,7 @@ void
 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));
 }
@@ -298,9 +299,11 @@ VideoPlayerPresentationModel::StartPlay(void)
        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:
@@ -444,7 +447,7 @@ VideoPlayerPresentationModel::StartPlay(void)
                break;
        }
 
-       CallOnPlayStateChanged(__pPlayer->GetState());
+       CallOnPlayStateChanged(GetState());
 
 CATCH:
        return r;
@@ -501,7 +504,7 @@ VideoPlayerPresentationModel::PausePlay(void)
                __stateAfterSeek = PLAYER_STATE_PAUSED;
        }
 
-       CallOnPlayStateChanged(__pPlayer->GetState());
+       CallOnPlayStateChanged(GetState());
 
 CATCH:
        return r;
@@ -537,18 +540,24 @@ CATCH:
 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();
 }
 
@@ -736,7 +745,7 @@ VideoPlayerPresentationModel::OnPlayerInterrupted(void)
        AppLogDebug("OnPlayerInterrupted");
        __pVideoPlayerEventListener->OnPlayInterrupted();
 
-       CallOnPlayStateChanged(__pPlayer->GetState());
+       CallOnPlayStateChanged(GetState());
 }
 
 void
@@ -744,7 +753,7 @@ VideoPlayerPresentationModel::OnPlayerAudioFocusChanged(void)
 {
        AppLogDebug("OnPlayerAudioFocusChanged");
 
-       CallOnPlayStateChanged(__pPlayer->GetState());
+       CallOnPlayStateChanged(GetState());
 }
 
 void
@@ -821,17 +830,19 @@ VideoPlayerPresentationModel::OnTimerExpired(Timer& timer)
        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);
 
@@ -840,8 +851,8 @@ VideoPlayerPresentationModel::OnTimerExpired(Timer& timer)
        }
        else if (timer.GetHashCode() == __pFastForwardTimer->GetHashCode())
        {
-               msTime = __pPlayer->GetPosition();
-               playerDuration = __pPlayer->GetDuration();
+               msTime = GetPosition();
+               playerDuration = GetDuration();
 
                msTime = msTime + (TWO_SEC * MILLISECOND);
 
@@ -859,7 +870,7 @@ VideoPlayerPresentationModel::OnTimerExpired(Timer& timer)
 
                                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);
                        }
@@ -877,7 +888,7 @@ VideoPlayerPresentationModel::OnTimerExpired(Timer& timer)
 
                                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);
                        }
@@ -886,8 +897,8 @@ VideoPlayerPresentationModel::OnTimerExpired(Timer& timer)
        }
        else if (timer.GetHashCode() == __pFastRewindTimer->GetHashCode())
        {
-               msTime = __pPlayer->GetPosition();
-               playerDuration = __pPlayer->GetDuration();
+               msTime = GetPosition();
+               playerDuration = GetDuration();
 
                msTime = msTime - (TWO_SEC * MILLISECOND);
 
@@ -905,7 +916,7 @@ VideoPlayerPresentationModel::OnTimerExpired(Timer& timer)
 
                                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);
                        }
@@ -943,14 +954,14 @@ VideoPlayerPresentationModel::Forward(void)
 
        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);
 
@@ -966,7 +977,7 @@ VideoPlayerPresentationModel::Forward(void)
 
                                        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);
 
@@ -986,7 +997,7 @@ VideoPlayerPresentationModel::Forward(void)
 
                                        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);
 
@@ -1011,12 +1022,12 @@ VideoPlayerPresentationModel::Rewind(void)
 
        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);
 
@@ -1031,7 +1042,7 @@ VideoPlayerPresentationModel::Rewind(void)
 
                                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);
 
@@ -1051,7 +1062,7 @@ VideoPlayerPresentationModel::Rewind(void)
 
                                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);
 
@@ -1067,7 +1078,7 @@ VideoPlayerPresentationModel::FastForward(bool playAfterSeek)
 {
        AppLogDebug("FastForward");
 
-       if (__pPlayer->GetState() != PLAYER_STATE_ENDOFCLIP)
+       if (GetState() != PLAYER_STATE_ENDOFCLIP)
        {
                PausePlay();
                if(playAfterSeek)
@@ -1088,7 +1099,7 @@ VideoPlayerPresentationModel::FastRewind(bool playAfterSeek)
 {
        AppLogDebug("FastRewind");
 
-       if (__pPlayer->GetState() != PLAYER_STATE_ENDOFCLIP)
+       if (GetState() != PLAYER_STATE_ENDOFCLIP)
        {
                PausePlay();
                if(playAfterSeek)
@@ -1109,7 +1120,7 @@ VideoPlayerPresentationModel::StopFastForwardRewind(void)
 {
        AppLogDebug("StopFastForwardRewind");
 
-       if (__pPlayer->GetState() != PLAYER_STATE_ENDOFCLIP)
+       if (GetState() != PLAYER_STATE_ENDOFCLIP)
        {
                __pFastForwardTimer->Cancel();
                __pFastRewindTimer->Cancel();
@@ -1118,10 +1129,10 @@ VideoPlayerPresentationModel::StopFastForwardRewind(void)
                {
                        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);
                        }
@@ -1230,15 +1241,13 @@ VideoPlayerPresentationModel::InitializePlayer(void)
        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;
 }
 
@@ -1259,7 +1268,7 @@ VideoPlayerPresentationModel::ChangeCurrentMediaIndex(void)
 {
        AppLogDebug("ChangeCurrentMediaIndex");
 
-       if (__pPlayer->GetState() == PLAYER_STATE_ENDOFCLIP)
+       if (GetState() == PLAYER_STATE_ENDOFCLIP)
        {
                switch (GetRepeatMode())
                {