videoplayback/videohelix/src/mpxvideoplaybackstate.cpp
changeset 1 6711b85517b7
parent 0 96612d01cf9f
child 6 7d91903f795f
--- a/videoplayback/videohelix/src/mpxvideoplaybackstate.cpp	Mon Jan 18 20:21:12 2010 +0200
+++ b/videoplayback/videohelix/src/mpxvideoplaybackstate.cpp	Tue Jan 26 12:00:59 2010 +0200
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 30 %
+// Version : %version: 31 %
 
 
 //
@@ -277,7 +277,7 @@
 {
     MPX_DEBUG(_L("CMPXVideoPlaybackState::HandleVolumeChange()"));
 
-    MPX_TRAPD(err, iVideoPlaybackCtlr->SetVolumeMMFL());
+    MPX_TRAPD( err, iVideoPlaybackCtlr->SetVolumeMMFL() );
 }
 
 //  ------------------------------------------------------------------------------------------------
@@ -665,6 +665,33 @@
     return 100;
 }
 
+//  ------------------------------------------------------------------------------------------------
+//    CMPXVideoPlaybackState::IssuePlayCommand()
+//  ------------------------------------------------------------------------------------------------
+void CMPXVideoPlaybackState::IssuePlayCommand( TMPXVideoPlaybackState aState,
+                                               MMPXPlaybackPluginObserver::TEvent aEvent, 
+                                               TBool aSendEvent )
+{
+    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::CMPXVideoPlaybackState::IssuePlayCommand()"),
+                   _L("aState = %d, aEvent  = %d, aSendEvent = %d"), aState, aEvent, aSendEvent );
+
+    MPX_TRAPD( err, iVideoPlaybackCtlr->iPlayer->PlayL() );
+
+    if ( err == KErrNone )
+    {
+        iVideoPlaybackCtlr->ChangeState( aState );
+    
+        if ( aSendEvent )
+        {
+            iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( aEvent, 0, KErrNone );
+        }
+    }
+    else
+    {
+        TRAP_IGNORE( SendErrorToViewL( err ) );
+    }
+}
+
 // *************************************************************************************************
 //
 //                          STATE SUB-CLASSES
@@ -1064,7 +1091,7 @@
 }
 
 //  ------------------------------------------------------------------------------------------------
-//  CMPXInitialisedState::HandlePlay()
+//    CMPXInitialisedState::HandlePlay()
 //  ------------------------------------------------------------------------------------------------
 void CMPXInitialisedState::HandlePlay()
 {
@@ -1074,13 +1101,7 @@
     {
         iVideoPlaybackCtlr->iForegroundPause = EFalse;
 
-        iVideoPlaybackCtlr->iPlayer->Play();
-
-        iVideoPlaybackCtlr->ChangeState( EMPXVideoBuffering );
-
-        iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPBufferingStarted,
-                                                              0,
-                                                              KErrNone );
+        IssuePlayCommand( EMPXVideoBuffering, MMPXPlaybackPluginObserver::EPBufferingStarted );
     }
     else
     {
@@ -1293,11 +1314,17 @@
         pos *= KPbMilliMultiplier;
 
         //
-        // Helix can't handle setposition in playing state
+        //  Helix can't handle set position in playing state
         //
         iVideoPlaybackCtlr->iPlayer->PauseL();
         iVideoPlaybackCtlr->iPlayer->SetPositionL( pos );
-        iVideoPlaybackCtlr->iPlayer->Play();
+
+        MPX_TRAPD( err, iVideoPlaybackCtlr->iPlayer->PlayL() );
+
+        if ( err != KErrNone )
+        {
+            SendErrorToViewL( err );
+        }
     }
     else
     {
@@ -1376,7 +1403,7 @@
 }
 
 //  ------------------------------------------------------------------------------------------------
-//  CMPXPausedState::HandlePlay()
+//    CMPXPausedState::HandlePlay()
 //  ------------------------------------------------------------------------------------------------
 void CMPXPausedState::HandlePlay()
 {
@@ -1386,13 +1413,7 @@
     {
         iVideoPlaybackCtlr->iForegroundPause = EFalse;
 
-        iVideoPlaybackCtlr->iPlayer->Play();
-
-        iVideoPlaybackCtlr->ChangeState(EMPXVideoPlaying);
-
-        iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPlaying,
-                                                              0,
-                                                              KErrNone );
+        IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying );
     }
 }
 
@@ -1488,8 +1509,9 @@
 }
 
 //  ------------------------------------------------------------------------------------------------
-//  CMPXPausedState::HandleCustomPlay()
-//  Handle the custom play command only when in paused state
+//    CMPXPausedState::HandleCustomPlay()
+//    Handle the custom play command only when in paused state.
+//    No state change is sent to the framework
 //  ------------------------------------------------------------------------------------------------
 void CMPXPausedState::HandleCustomPlay()
 {
@@ -1499,9 +1521,7 @@
     {
         iVideoPlaybackCtlr->iForegroundPause = EFalse;
 
-        iVideoPlaybackCtlr->iPlayer->Play();
-
-        iVideoPlaybackCtlr->ChangeState(EMPXVideoPlaying);
+        IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying, EFalse );
     }
 }
 
@@ -1541,13 +1561,7 @@
 
     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
     {
-        iVideoPlaybackCtlr->iPlayer->Play();
-
-        iVideoPlaybackCtlr->ChangeState(EMPXVideoPlaying);
-
-        iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPlaying,
-                                                              0,
-                                                              KErrNone );
+        IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying );
     }
 }
 
@@ -1781,7 +1795,7 @@
 }
 
 //  ------------------------------------------------------------------------------------------------
-//  CMPXSeekingState::HandlePlay()
+//    CMPXSeekingState::HandlePlay()
 //  ------------------------------------------------------------------------------------------------
 void CMPXSeekingState::HandlePlay()
 {
@@ -1789,13 +1803,7 @@
 
     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
     {
-        iVideoPlaybackCtlr->iPlayer->Play();
-
-        iVideoPlaybackCtlr->ChangeState( EMPXVideoPlaying );
-
-        iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPlaying,
-                                                              0,
-                                                              KErrNone );
+        IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying );
     }
     else
     {