videoplayback/videohelix/src/mpxvideoplaybackstate.cpp
changeset 1 6711b85517b7
parent 0 96612d01cf9f
child 6 7d91903f795f
equal deleted inserted replaced
0:96612d01cf9f 1:6711b85517b7
    13 *
    13 *
    14 * Description:  This class plays local video file
    14 * Description:  This class plays local video file
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 30 %
    18 // Version : %version: 31 %
    19 
    19 
    20 
    20 
    21 //
    21 //
    22 //  INCLUDE FILES
    22 //  INCLUDE FILES
    23 //
    23 //
   275 //  ------------------------------------------------------------------------------------------------
   275 //  ------------------------------------------------------------------------------------------------
   276 void CMPXVideoPlaybackState::HandleVolumeChange()
   276 void CMPXVideoPlaybackState::HandleVolumeChange()
   277 {
   277 {
   278     MPX_DEBUG(_L("CMPXVideoPlaybackState::HandleVolumeChange()"));
   278     MPX_DEBUG(_L("CMPXVideoPlaybackState::HandleVolumeChange()"));
   279 
   279 
   280     MPX_TRAPD(err, iVideoPlaybackCtlr->SetVolumeMMFL());
   280     MPX_TRAPD( err, iVideoPlaybackCtlr->SetVolumeMMFL() );
   281 }
   281 }
   282 
   282 
   283 //  ------------------------------------------------------------------------------------------------
   283 //  ------------------------------------------------------------------------------------------------
   284 //    CMPXVideoPlaybackState::HandleSetPositionL()
   284 //    CMPXVideoPlaybackState::HandleSetPositionL()
   285 //  ------------------------------------------------------------------------------------------------
   285 //  ------------------------------------------------------------------------------------------------
   663 {
   663 {
   664     MPX_DEBUG(_L("CMPXVideoPlaybackState::RetrieveBufferingPercentage()"));
   664     MPX_DEBUG(_L("CMPXVideoPlaybackState::RetrieveBufferingPercentage()"));
   665     return 100;
   665     return 100;
   666 }
   666 }
   667 
   667 
       
   668 //  ------------------------------------------------------------------------------------------------
       
   669 //    CMPXVideoPlaybackState::IssuePlayCommand()
       
   670 //  ------------------------------------------------------------------------------------------------
       
   671 void CMPXVideoPlaybackState::IssuePlayCommand( TMPXVideoPlaybackState aState,
       
   672                                                MMPXPlaybackPluginObserver::TEvent aEvent, 
       
   673                                                TBool aSendEvent )
       
   674 {
       
   675     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::CMPXVideoPlaybackState::IssuePlayCommand()"),
       
   676                    _L("aState = %d, aEvent  = %d, aSendEvent = %d"), aState, aEvent, aSendEvent );
       
   677 
       
   678     MPX_TRAPD( err, iVideoPlaybackCtlr->iPlayer->PlayL() );
       
   679 
       
   680     if ( err == KErrNone )
       
   681     {
       
   682         iVideoPlaybackCtlr->ChangeState( aState );
       
   683     
       
   684         if ( aSendEvent )
       
   685         {
       
   686             iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( aEvent, 0, KErrNone );
       
   687         }
       
   688     }
       
   689     else
       
   690     {
       
   691         TRAP_IGNORE( SendErrorToViewL( err ) );
       
   692     }
       
   693 }
       
   694 
   668 // *************************************************************************************************
   695 // *************************************************************************************************
   669 //
   696 //
   670 //                          STATE SUB-CLASSES
   697 //                          STATE SUB-CLASSES
   671 //
   698 //
   672 // *************************************************************************************************
   699 // *************************************************************************************************
  1062 {
  1089 {
  1063     MPX_DEBUG(_L("CMPXInitialisedState::~CMPXInitialisedState()"));
  1090     MPX_DEBUG(_L("CMPXInitialisedState::~CMPXInitialisedState()"));
  1064 }
  1091 }
  1065 
  1092 
  1066 //  ------------------------------------------------------------------------------------------------
  1093 //  ------------------------------------------------------------------------------------------------
  1067 //  CMPXInitialisedState::HandlePlay()
  1094 //    CMPXInitialisedState::HandlePlay()
  1068 //  ------------------------------------------------------------------------------------------------
  1095 //  ------------------------------------------------------------------------------------------------
  1069 void CMPXInitialisedState::HandlePlay()
  1096 void CMPXInitialisedState::HandlePlay()
  1070 {
  1097 {
  1071     MPX_DEBUG(_L("CMPXInitialisedState::HandlePlay()"));
  1098     MPX_DEBUG(_L("CMPXInitialisedState::HandlePlay()"));
  1072 
  1099 
  1073     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1100     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1074     {
  1101     {
  1075         iVideoPlaybackCtlr->iForegroundPause = EFalse;
  1102         iVideoPlaybackCtlr->iForegroundPause = EFalse;
  1076 
  1103 
  1077         iVideoPlaybackCtlr->iPlayer->Play();
  1104         IssuePlayCommand( EMPXVideoBuffering, MMPXPlaybackPluginObserver::EPBufferingStarted );
  1078 
       
  1079         iVideoPlaybackCtlr->ChangeState( EMPXVideoBuffering );
       
  1080 
       
  1081         iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPBufferingStarted,
       
  1082                                                               0,
       
  1083                                                               KErrNone );
       
  1084     }
  1105     }
  1085     else
  1106     else
  1086     {
  1107     {
  1087         iVideoPlaybackCtlr->iPlaybackMode->HandlePause();
  1108         iVideoPlaybackCtlr->iPlaybackMode->HandlePause();
  1088     }
  1109     }
  1291         TInt64 pos( aPosition );
  1312         TInt64 pos( aPosition );
  1292 
  1313 
  1293         pos *= KPbMilliMultiplier;
  1314         pos *= KPbMilliMultiplier;
  1294 
  1315 
  1295         //
  1316         //
  1296         // Helix can't handle setposition in playing state
  1317         //  Helix can't handle set position in playing state
  1297         //
  1318         //
  1298         iVideoPlaybackCtlr->iPlayer->PauseL();
  1319         iVideoPlaybackCtlr->iPlayer->PauseL();
  1299         iVideoPlaybackCtlr->iPlayer->SetPositionL( pos );
  1320         iVideoPlaybackCtlr->iPlayer->SetPositionL( pos );
  1300         iVideoPlaybackCtlr->iPlayer->Play();
  1321 
       
  1322         MPX_TRAPD( err, iVideoPlaybackCtlr->iPlayer->PlayL() );
       
  1323 
       
  1324         if ( err != KErrNone )
       
  1325         {
       
  1326             SendErrorToViewL( err );
       
  1327         }
  1301     }
  1328     }
  1302     else
  1329     else
  1303     {
  1330     {
  1304         MPX_DEBUG(_L("CMPXPlayingState::HandleSetPosition() FAIL - file is not seekable"));
  1331         MPX_DEBUG(_L("CMPXPlayingState::HandleSetPosition() FAIL - file is not seekable"));
  1305     }
  1332     }
  1374 {
  1401 {
  1375     MPX_DEBUG(_L("CMPXPausedState::~CMPXPausedState()"));
  1402     MPX_DEBUG(_L("CMPXPausedState::~CMPXPausedState()"));
  1376 }
  1403 }
  1377 
  1404 
  1378 //  ------------------------------------------------------------------------------------------------
  1405 //  ------------------------------------------------------------------------------------------------
  1379 //  CMPXPausedState::HandlePlay()
  1406 //    CMPXPausedState::HandlePlay()
  1380 //  ------------------------------------------------------------------------------------------------
  1407 //  ------------------------------------------------------------------------------------------------
  1381 void CMPXPausedState::HandlePlay()
  1408 void CMPXPausedState::HandlePlay()
  1382 {
  1409 {
  1383     MPX_ENTER_EXIT(_L("CMPXPausedState::HandlePlay()"));
  1410     MPX_ENTER_EXIT(_L("CMPXPausedState::HandlePlay()"));
  1384 
  1411 
  1385     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1412     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1386     {
  1413     {
  1387         iVideoPlaybackCtlr->iForegroundPause = EFalse;
  1414         iVideoPlaybackCtlr->iForegroundPause = EFalse;
  1388 
  1415 
  1389         iVideoPlaybackCtlr->iPlayer->Play();
  1416         IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying );
  1390 
       
  1391         iVideoPlaybackCtlr->ChangeState(EMPXVideoPlaying);
       
  1392 
       
  1393         iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPlaying,
       
  1394                                                               0,
       
  1395                                                               KErrNone );
       
  1396     }
  1417     }
  1397 }
  1418 }
  1398 
  1419 
  1399 //  ------------------------------------------------------------------------------------------------
  1420 //  ------------------------------------------------------------------------------------------------
  1400 //    CMPXPausedState::HandlePlayPause()
  1421 //    CMPXPausedState::HandlePlayPause()
  1486         iVideoPlaybackCtlr->iState->HandlePlay();
  1507         iVideoPlaybackCtlr->iState->HandlePlay();
  1487     }
  1508     }
  1488 }
  1509 }
  1489 
  1510 
  1490 //  ------------------------------------------------------------------------------------------------
  1511 //  ------------------------------------------------------------------------------------------------
  1491 //  CMPXPausedState::HandleCustomPlay()
  1512 //    CMPXPausedState::HandleCustomPlay()
  1492 //  Handle the custom play command only when in paused state
  1513 //    Handle the custom play command only when in paused state.
       
  1514 //    No state change is sent to the framework
  1493 //  ------------------------------------------------------------------------------------------------
  1515 //  ------------------------------------------------------------------------------------------------
  1494 void CMPXPausedState::HandleCustomPlay()
  1516 void CMPXPausedState::HandleCustomPlay()
  1495 {
  1517 {
  1496     MPX_ENTER_EXIT(_L("CMPXPausedState::HandleCustomPlay()"));
  1518     MPX_ENTER_EXIT(_L("CMPXPausedState::HandleCustomPlay()"));
  1497 
  1519 
  1498     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1520     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1499     {
  1521     {
  1500         iVideoPlaybackCtlr->iForegroundPause = EFalse;
  1522         iVideoPlaybackCtlr->iForegroundPause = EFalse;
  1501 
  1523 
  1502         iVideoPlaybackCtlr->iPlayer->Play();
  1524         IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying, EFalse );
  1503 
       
  1504         iVideoPlaybackCtlr->ChangeState(EMPXVideoPlaying);
       
  1505     }
  1525     }
  1506 }
  1526 }
  1507 
  1527 
  1508 // *************************************************************************************************
  1528 // *************************************************************************************************
  1509 //
  1529 //
  1539 {
  1559 {
  1540     MPX_DEBUG(_L("CMPXStoppedState::HandlePlay()"));
  1560     MPX_DEBUG(_L("CMPXStoppedState::HandlePlay()"));
  1541 
  1561 
  1542     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1562     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1543     {
  1563     {
  1544         iVideoPlaybackCtlr->iPlayer->Play();
  1564         IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying );
  1545 
       
  1546         iVideoPlaybackCtlr->ChangeState(EMPXVideoPlaying);
       
  1547 
       
  1548         iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPlaying,
       
  1549                                                               0,
       
  1550                                                               KErrNone );
       
  1551     }
  1565     }
  1552 }
  1566 }
  1553 
  1567 
  1554 //  ------------------------------------------------------------------------------------------------
  1568 //  ------------------------------------------------------------------------------------------------
  1555 //  CMPXStoppedState::HandleSetPositionL()
  1569 //  CMPXStoppedState::HandleSetPositionL()
  1779 {
  1793 {
  1780     MPX_DEBUG(_L("CMPXSeekingState::~CMPXSeekingState()"));
  1794     MPX_DEBUG(_L("CMPXSeekingState::~CMPXSeekingState()"));
  1781 }
  1795 }
  1782 
  1796 
  1783 //  ------------------------------------------------------------------------------------------------
  1797 //  ------------------------------------------------------------------------------------------------
  1784 //  CMPXSeekingState::HandlePlay()
  1798 //    CMPXSeekingState::HandlePlay()
  1785 //  ------------------------------------------------------------------------------------------------
  1799 //  ------------------------------------------------------------------------------------------------
  1786 void CMPXSeekingState::HandlePlay()
  1800 void CMPXSeekingState::HandlePlay()
  1787 {
  1801 {
  1788     MPX_DEBUG(_L("CMPXSeekingState::HandlePlay()"));
  1802     MPX_DEBUG(_L("CMPXSeekingState::HandlePlay()"));
  1789 
  1803 
  1790     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1804     if ( iVideoPlaybackCtlr->iPlaybackMode->CanPlayNow() )
  1791     {
  1805     {
  1792         iVideoPlaybackCtlr->iPlayer->Play();
  1806         IssuePlayCommand( EMPXVideoPlaying, MMPXPlaybackPluginObserver::EPPlaying );
  1793 
       
  1794         iVideoPlaybackCtlr->ChangeState( EMPXVideoPlaying );
       
  1795 
       
  1796         iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPlaying,
       
  1797                                                               0,
       
  1798                                                               KErrNone );
       
  1799     }
  1807     }
  1800     else
  1808     else
  1801     {
  1809     {
  1802         iVideoPlaybackCtlr->iPlaybackMode->HandlePause();
  1810         iVideoPlaybackCtlr->iPlaybackMode->HandlePause();
  1803     }
  1811     }