videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp
changeset 15 cf5481c2bc0b
parent 2 dec420019252
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
    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: ou1cpsw#41 %
    18 // Version : %version: 50 %
    19 
    19 
    20 
    20 
    21 //
    21 //
    22 //  INCLUDE FILES
    22 //  INCLUDE FILES
    23 //
    23 //
    36 
    36 
    37 #include <coreapplicationuisdomainpskeys.h>
    37 #include <coreapplicationuisdomainpskeys.h>
    38 #include <ctsydomainpskeys.h>
    38 #include <ctsydomainpskeys.h>
    39 #include <mmf/common/mmferrors.h>
    39 #include <mmf/common/mmferrors.h>
    40 
    40 
    41 #include <hal.h>
       
    42 #include <hal_data.h>
       
    43 #include <e32std.h>
    41 #include <e32std.h>
    44 #include <devsoundif.h>
    42 #include <devsoundif.h>
       
    43 #include <avkondomainpskeys.h>
       
    44 #include <hwrmlight.h>  
       
    45 #include <centralrepository.h>  // For display timeout setting
       
    46 #include <hwrmlightdomaincrkeys.h>
    45 
    47 
    46 #include "mpxvideoregion.h"
    48 #include "mpxvideoregion.h"
    47 #include "mpxvideoplaybackcontroller.h"
    49 #include "mpxvideoplaybackcontroller.h"
    48 #include "mpxvideoplaybackstate.h"
    50 #include "mpxvideoplaybackstate.h"
    49 #include "mpxvideoprivatecrkeys.h"
    51 #include "mpxvideoprivatecrkeys.h"
    60 #define KMAXMIMETYPELENGTH 256
    62 #define KMAXMIMETYPELENGTH 256
    61 
    63 
    62 //
    64 //
    63 //  Backlight Timeout in Micro Seconds
    65 //  Backlight Timeout in Micro Seconds
    64 //
    66 //
    65 #define KMPXBackLightTimeOut 3500000
    67 const TInt KMPXBackLightTimeOut = 3500000;
       
    68 const TInt KMPXInactivityTimeout  = 3 * KMPXBackLightTimeOut;
       
    69 const TInt KMPXMicroSecondsInASecond = 1000000;
    66 
    70 
    67 #define KOneKilobyte 1024
    71 #define KOneKilobyte 1024
    68 
    72 
    69 _LIT( KTitle, "Title" );
    73 _LIT( KTitle, "Title" );
    70 _LIT( KLiveStream, "LiveStream" );
    74 _LIT( KLiveStream, "LiveStream" );
    73 _LIT( KAuthor, "Author" );
    77 _LIT( KAuthor, "Author" );
    74 _LIT( KFormat, "MimeType" );
    78 _LIT( KFormat, "MimeType" );
    75 _LIT( KTrue, "1" );
    79 _LIT( KTrue, "1" );
    76 _LIT( KFalse, "0" );
    80 _LIT( KFalse, "0" );
    77 _LIT (KMPStreamingPauseSupported, "StreamingPauseSupported");
    81 _LIT (KMPStreamingPauseSupported, "StreamingPauseSupported");
       
    82 _LIT( KDescription, "Description" );
       
    83 _LIT( KAbstract, "Abstract" );
       
    84 _LIT( KLocation, "Location" );
       
    85 _LIT( KRightCopy, "Copyright" );
       
    86 _LIT( KLanguage, "Language" );
       
    87 _LIT( KKeywords, "Keywords" );
    78 
    88 
    79 
    89 
    80 // ============================ MEMBER FUNCTIONS ===================================================
    90 // ============================ MEMBER FUNCTIONS ===================================================
    81 
    91 
    82 //  ------------------------------------------------------------------------------------------------
    92 //  ------------------------------------------------------------------------------------------------
   137 void CMPXVideoPlaybackController::ConstructL( MMPXPlaybackPluginObserver& aObs )
   147 void CMPXVideoPlaybackController::ConstructL( MMPXPlaybackPluginObserver& aObs )
   138 {
   148 {
   139     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::ConstructL()"));
   149     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::ConstructL()"));
   140 
   150 
   141     iMPXPluginObs = &aObs;
   151     iMPXPluginObs = &aObs;
   142     iAccessPointId = -1;
   152     iAccessPointId = KUseDefaultIap;
   143     iVideoSeeker = CMPXVideoSeeker::NewL( this );
   153     iVideoSeeker = CMPXVideoSeeker::NewL( this );
   144 
   154 
   145     // Initiliaze to True
   155     // Initiliaze to True
   146     iSeekable = ETrue;
   156     iSeekable = ETrue;
   147 
   157 
   148     InitVolumeWatchers();
   158     InitVolumeWatchersL();
   149 
   159 
   150     CreatePreInitStatesL();
   160     CreatePreInitStatesL();
   151 
   161 
   152     iPlayer = CMpxVideoPlayerUtility::NewL( this );
   162     iPlayer = CMpxVideoPlayerUtility::NewL( this );
   153 
   163 
   154     iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   164     iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   155 
   165 
   156     iDrmHelper = CMpxVideoDrmHelper::NewL();
   166     iDrmHelper = CMpxVideoDrmHelper::NewL();
       
   167     
       
   168     iSavedPosition = 0;
   157 }
   169 }
   158 
   170 
   159 //  ----------------------------------------------------------------------------
   171 //  ----------------------------------------------------------------------------
   160 //  CMPXVideoPlaybackController::CloseController()
   172 //  CMPXVideoPlaybackController::CloseController()
   161 //  ----------------------------------------------------------------------------
   173 //  ----------------------------------------------------------------------------
   162 //
   174 //
   163 void CMPXVideoPlaybackController::CloseController()
   175 void CMPXVideoPlaybackController::CloseController()
   164 {
   176 {
   165     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CloseController()"));
   177     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CloseController()"));
   166 
       
   167     ChangeState( EMPXVideoNotInitialized );
   178     ChangeState( EMPXVideoNotInitialized );
   168 }
   179 }
   169 
   180 
   170 //  ------------------------------------------------------------------------------------------------
   181 //  ------------------------------------------------------------------------------------------------
   171 //    CMPXVideoPlaybackController::OpenFileL()
   182 //    CMPXVideoPlaybackController::OpenFileL()
   172 //  ------------------------------------------------------------------------------------------------
   183 //  ------------------------------------------------------------------------------------------------
   173 //
   184 //
   174 void CMPXVideoPlaybackController::OpenFileL( const TDesC& aMediaFile,
   185 void CMPXVideoPlaybackController::OpenFileL( const TDesC& aMediaFile,
   175                                              RFile& aFile,
   186                                              RFile& aFile,
   176                                              TInt aAccessPointId )
   187                                              TInt aPosition,
       
   188                                              TInt aAccessPointId ) 
   177 {
   189 {
   178     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::OpenFileL()"),
   190     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::OpenFileL()"),
   179                    _L("file = %S"), &aMediaFile );
   191                    _L("file = %S"), &aMediaFile );
   180 
   192 
   181     TBool fileExists = EFalse;
   193     TBool fileExists = EFalse;
   201     }
   213     }
   202 
   214 
   203     DetermineMediaTypeL();
   215     DetermineMediaTypeL();
   204     SetPlaybackModeL();
   216     SetPlaybackModeL();
   205 
   217 
       
   218     iSavedPosition = aPosition;
       
   219     
   206     //
   220     //
   207     //  Create accessory monitor to search for TV-Out events
   221     //  Create accessory monitor to search for TV-Out events
   208     //
   222     //
   209     if ( ! iAccessoryMonitor )
   223     if ( ! iAccessoryMonitor )
   210     {
   224     {
   250 CMPXVideoPlaybackController::CMPXVideoPlaybackController()
   264 CMPXVideoPlaybackController::CMPXVideoPlaybackController()
   251     : iAppInForeground(ETrue)
   265     : iAppInForeground(ETrue)
   252     , iForegroundPause(EFalse)
   266     , iForegroundPause(EFalse)
   253     , iAllowAutoPlay(ETrue)
   267     , iAllowAutoPlay(ETrue)
   254     , iHelixLoadingStarted(EFalse)
   268     , iHelixLoadingStarted(EFalse)
       
   269     , iLightStatus(CHWRMLight::ELightStatusUnknown)
   255 {
   270 {
   256 }
   271 }
   257 
   272 
   258 //  ----------------------------------------------------------------------------
   273 //  ----------------------------------------------------------------------------
   259 //    Destructor
   274 //    Destructor
   332     if ( iPlayer )
   347     if ( iPlayer )
   333     {
   348     {
   334         delete iPlayer;
   349         delete iPlayer;
   335         iPlayer = NULL;
   350         iPlayer = NULL;
   336     }
   351     }
       
   352    
       
   353     if ( iUserActivityTimer )
       
   354     {
       
   355         iUserActivityTimer->Cancel();
       
   356         delete iUserActivityTimer;
       
   357         iUserActivityTimer = NULL;
       
   358     }
       
   359     
       
   360     ReleaseLights();
       
   361     
       
   362     CancelDisplayTimer();
   337 
   363 
   338 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   364 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   339 
   365 
   340     if ( iFileHandle64.SubSessionHandle() )
   366     if ( iFileHandle64.SubSessionHandle() )
   341     {
   367     {
   515                 }
   541                 }
   516 
   542 
   517                 aCmd.SetTObjectValueL<TInt>( KMPXMediaVideoBufferingPercentage,
   543                 aCmd.SetTObjectValueL<TInt>( KMPXMediaVideoBufferingPercentage,
   518                                              bufferingPercentage );
   544                                              bufferingPercentage );
   519 
   545 
       
   546                 break;
       
   547             }
       
   548             case EPbCmdSurfaceRemoved:
       
   549             {
       
   550                 iPlayer->SurfaceRemovedFromView();
   520                 break;
   551                 break;
   521             }
   552             }
   522             default:
   553             default:
   523             {
   554             {
   524                 break;
   555                 break;
   967     {
   998     {
   968         switch ( aSettingId )
   999         switch ( aSettingId )
   969         {
  1000         {
   970             case KMPXVideoPlaybackMute:
  1001             case KMPXVideoPlaybackMute:
   971             {
  1002             {
       
  1003                 TInt muteValue( EFalse );
       
  1004 
       
  1005                 TRAP_IGNORE( muteValue = iMuteWatcher->CurrentValueL() );
       
  1006 
   972                 iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPMuteChanged,
  1007                 iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPMuteChanged,
   973                                                   iMuteWatcher->CurrentValueL(),
  1008                                                   muteValue,
   974                                                   KErrNone );
  1009                                                   KErrNone );
   975                 // fall through
  1010                 // fall through
   976             }
  1011             }
   977             case KMPXVideoPlaybackVolume:
  1012             case KMPXVideoPlaybackVolume:
   978             {
  1013             {
   979                 //
  1014                 //
   980                 //  this is the callback from cen-rep
  1015                 //  this is the callback from cen-rep
   981                 //  let the state decide if it needs to do something
  1016                 //  let the state decide if it needs to do something
   982                 //
  1017                 //
   983                 iState->HandleVolumeChange();
  1018                 iState->HandleVolumeChange();
   984                 break;
       
   985             }
       
   986             default:
       
   987             {
       
   988                 break;
  1019                 break;
   989             }
  1020             }
   990         }
  1021         }
   991     }
  1022     }
   992 }
  1023 }
  1178                 //  If clip has audio and video, proceed to the next case which will
  1209                 //  If clip has audio and video, proceed to the next case which will
  1179                 //  start the backlight timer if needed
  1210                 //  start the backlight timer if needed
  1180                 //
  1211                 //
  1181                 if ( iFileDetails->iVideoEnabled )
  1212                 if ( iFileDetails->iVideoEnabled )
  1182                 {
  1213                 {
  1183                     StartBackLightTimer();
  1214                     StartLightsControl();
  1184                 }
  1215                 }
  1185                 else
  1216                 else
  1186                 {
  1217                 {
  1187                     CancelBackLightTimer();
  1218                     CancelLightsControl();
  1188                 }
  1219                 }
  1189                 
  1220                 
  1190                 break;
  1221                 break;
  1191             }
  1222             }
  1192             case EMPXVideoPaused:
  1223             case EMPXVideoPaused:
  1193             {
  1224             {
  1194                 iState = iPausedState;
  1225                 iState = iPausedState;
  1195                 CancelBackLightTimer();
  1226                 CancelLightsControl();
  1196                 break;
  1227                 break;
  1197             }
  1228             }
  1198             case EMPXVideoInitializing:
  1229             case EMPXVideoInitializing:
  1199             {
  1230             {
  1200                 iState = iInitialisingState;
  1231                 iState = iInitialisingState;
  1201                 StartBackLightTimer();
  1232                 StartLightsControl();
  1202                 break;
  1233                 break;
  1203             }
  1234             }
  1204             case EMPXVideoInitialized:
  1235             case EMPXVideoInitialized:
  1205             {
  1236             {
  1206                 iState = iInitialisedState;
  1237                 iState = iInitialisedState;
       
  1238                 StartLightsControl();
  1207                 break;
  1239                 break;
  1208             }
  1240             }
  1209             case EMPXVideoBuffering:
  1241             case EMPXVideoBuffering:
  1210             {
  1242             {
  1211                 iState = iBufferingState;
  1243                 iState = iBufferingState;
  1212                 StartBackLightTimer();
  1244                 StartLightsControl();
  1213                 break;
  1245                 break;
  1214             }
  1246             }
  1215             case EMPXVideoSeeking:
  1247             case EMPXVideoSeeking:
  1216             {
  1248             {
  1217                 iState = iSeekingState;
  1249                 iState = iSeekingState;
       
  1250                 StartLightsControl();
  1218                 break;
  1251                 break;
  1219             }
  1252             }
  1220             case EMPXVideoStopped:
  1253             case EMPXVideoStopped:
  1221             {
  1254             {
  1222                 iState = iStoppedState;
  1255                 iState = iStoppedState;
  1223                 CancelBackLightTimer();
  1256                 CancelLightsControl();
  1224                 break;
  1257                 break;
  1225             }
  1258             }
  1226             case EMPXVideoNotInitialized:
  1259             case EMPXVideoNotInitialized:
  1227             {
  1260             {
  1228                 ResetMemberVariables();
  1261                 ResetMemberVariables();
  1229                 iState = iNotIntialisedState;
  1262                 iState = iNotIntialisedState;
  1230                 CancelBackLightTimer();
  1263                 CancelLightsControl();
  1231                 break;
  1264                 break;
  1232             }
  1265             }
  1233         }
  1266         }
  1234     }
  1267     }
  1235 }
  1268 }
  1271     //
  1304     //
  1272     // Drm Protected
  1305     // Drm Protected
  1273     //
  1306     //
  1274     if ( iFileHandle.SubSessionHandle() )
  1307     if ( iFileHandle.SubSessionHandle() )
  1275     {
  1308     {
  1276         iFileDetails->iDrmProtected = iDrmHelper->IsProtected( iFileHandle );
  1309         iFileDetails->iDrmProtected = iDrmHelper->IsProtectedL( iFileHandle );
  1277     }
  1310     }
  1278 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1311 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1279     else if ( iFileHandle64.SubSessionHandle() )
  1312     else if ( iFileHandle64.SubSessionHandle() )
  1280     {
  1313     {
  1281         iFileDetails->iDrmProtected = iDrmHelper->IsProtected64( iFileHandle64 );
  1314         iFileDetails->iDrmProtected = iDrmHelper->IsProtected64L( iFileHandle64 );
  1282     }
  1315     }
  1283 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1316 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  1284 
  1317 
  1285 
  1318 
  1286     //
  1319     //
  1296     //
  1329     //
  1297     //  Max Volume
  1330     //  Max Volume
  1298     //
  1331     //
  1299     iFileDetails->iMaxVolume = iPlayer->MaxVolume();
  1332     iFileDetails->iMaxVolume = iPlayer->MaxVolume();
  1300 
  1333 
  1301     // 
  1334     //
  1302     //  FourCC Code
  1335     //  FourCC Code
  1303     //
  1336     //
  1304     iFileDetails->iFourCCCode  = iPlayer->FourCCCode();    
  1337     iFileDetails->iFourCCCode  = iPlayer->FourCCCode();
  1305     
  1338 
  1306     //
  1339     //
  1307     //  Mime Type
  1340     //  Mime Type
  1308     //
  1341     //
  1309     HBufC8* mimeType = HBufC8::NewL( KMAXMIMETYPELENGTH );
  1342     HBufC8* mimeType = HBufC8::NewL( KMAXMIMETYPELENGTH );
  1310     CleanupStack::PushL( mimeType );
  1343     CleanupStack::PushL( mimeType );
  1362                 iFileDetails->iTitle = metaData->Value().AllocL();
  1395                 iFileDetails->iTitle = metaData->Value().AllocL();
  1363             }
  1396             }
  1364             else if ( ( ! metaData->Name().CompareF( KArtist ) ) ||
  1397             else if ( ( ! metaData->Name().CompareF( KArtist ) ) ||
  1365                       ( ! metaData->Name().CompareF( KAuthor ) ) )
  1398                       ( ! metaData->Name().CompareF( KAuthor ) ) )
  1366             {
  1399             {
  1367                 iFileDetails->iArtist = metaData->Value().AllocL();
  1400                 //
       
  1401                 //  Do not overwrite the artist
       
  1402                 //
       
  1403                 if ( ! iFileDetails->iArtist )
       
  1404                 {
       
  1405                     iFileDetails->iArtist = metaData->Value().AllocL();
       
  1406                 }
  1368             }
  1407             }
  1369             else if ( ! metaData->Name().CompareF( KFormat ) )
  1408             else if ( ! metaData->Name().CompareF( KFormat ) )
  1370             {
  1409             {
  1371                 //
  1410                 //
  1372                 //  Do not overwrite the mime type
  1411                 //  Do not overwrite the mime type
  1381                 if ( ! metaData->Value().CompareF( KFalse ) )
  1420                 if ( ! metaData->Value().CompareF( KFalse ) )
  1382                 {
  1421                 {
  1383                     // Streaming Pause is not supported by server
  1422                     // Streaming Pause is not supported by server
  1384                     iFileDetails->iPausableStream = EFalse;
  1423                     iFileDetails->iPausableStream = EFalse;
  1385                 }
  1424                 }
       
  1425             }
       
  1426             else if ( ( ! metaData->Name().CompareF( KDescription ) ) ||
       
  1427                       ( ! metaData->Name().CompareF( KAbstract ) ) )
       
  1428             {
       
  1429                 //
       
  1430                 //  Do not overwrite the description
       
  1431                 //
       
  1432                 if ( ! iFileDetails->iDescription )
       
  1433                 {
       
  1434                     iFileDetails->iDescription = metaData->Value().AllocL();
       
  1435                 }
       
  1436             }
       
  1437             else if ( !metaData->Name().CompareF( KLocation ) )
       
  1438             {
       
  1439                 iFileDetails->iLocation = metaData->Value().AllocL();
       
  1440             }
       
  1441             else if ( !metaData->Name().CompareF( KRightCopy ) )
       
  1442             {
       
  1443                 iFileDetails->iCopyright = metaData->Value().AllocL();
       
  1444             }
       
  1445             else if ( !metaData->Name().CompareF( KLanguage ) )
       
  1446             {
       
  1447                 iFileDetails->iLanguage = metaData->Value().AllocL();
       
  1448             }
       
  1449             else if ( !metaData->Name().CompareF( KKeywords ) )
       
  1450             {
       
  1451                 iFileDetails->iKeywords = metaData->Value().AllocL();
  1386             }
  1452             }
  1387 
  1453 
  1388             CleanupStack::PopAndDestroy( metaData );
  1454             CleanupStack::PopAndDestroy( metaData );
  1389         }
  1455         }
  1390 
  1456 
  1684 
  1750 
  1685     return alarm;
  1751     return alarm;
  1686 }
  1752 }
  1687 
  1753 
  1688 // -----------------------------------------------------------------------------
  1754 // -----------------------------------------------------------------------------
  1689 // CMPXVideoPlaybackController::IsDisplayOff
  1755 // CMPXVideoPlaybackController::IsKeyLocked
  1690 // -----------------------------------------------------------------------------
  1756 // -----------------------------------------------------------------------------
  1691 //
  1757 //
  1692 TBool CMPXVideoPlaybackController::IsDisplayOff()
  1758 TBool CMPXVideoPlaybackController::IsKeyLocked()
  1693 {
  1759 {
  1694     TBool displayState;
  1760     TBool keylock( EFalse );
  1695     HAL::Get( HALData::EDisplayState, displayState );
  1761     RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock );
  1696 
  1762 
  1697     MPX_DEBUG(_L("CMPXVideoPlaybackController::IsDisplayOff(%d)"), !displayState);
  1763     MPX_DEBUG(_L("CMPXVideoPlaybackController::IsKeyLocked(%d)"), keylock);
  1698 
  1764 
  1699     return !displayState;
  1765     return keylock;
  1700 }
  1766 }
  1701 
  1767 
  1702 //  ------------------------------------------------------------------------------------------------
  1768 //  ------------------------------------------------------------------------------------------------
  1703 //    CMPXVideoPlaybackController::HandleTvOutEventL()
  1769 //    CMPXVideoPlaybackController::HandleTvOutEventL()
  1704 //  ------------------------------------------------------------------------------------------------
  1770 //  ------------------------------------------------------------------------------------------------
  1725 
  1791 
  1726             playbackAllowed = EFalse;
  1792             playbackAllowed = EFalse;
  1727 
  1793 
  1728             iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed );
  1794             iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed );
  1729         }
  1795         }
       
  1796         else
       
  1797         {
       
  1798             // If lights are being controlled enable display timer so that screen backlight will be turned
       
  1799             // of after timeout.
       
  1800             if ( iBackLightTimer->IsActive() )
       
  1801             {
       
  1802                 RestartDisplayTimer();
       
  1803             }
       
  1804          } 
       
  1805     }
       
  1806     else 
       
  1807     {
       
  1808         // TV out disconnected
       
  1809         CancelDisplayTimer();
       
  1810         
       
  1811         // Ensure that lights are on after this 
       
  1812         ReleaseLights();
       
  1813         
       
  1814         // Pause playback since TV-Out accessory has been disconnected.
       
  1815         DoHandleCommandL( EPbCmdPause );
  1730     }
  1816     }
  1731 
  1817 
  1732     //
  1818     //
  1733     //  Send notice to the playback view with TV-Out connection status
  1819     //  Send notice to the playback view with TV-Out connection status
  1734     //  and TV-Out playback allowed flag
  1820     //  and TV-Out playback allowed flag
  1756 
  1842 
  1757     if ( iBackLightTimer->IsActive() )
  1843     if ( iBackLightTimer->IsActive() )
  1758     {
  1844     {
  1759         iBackLightTimer->Cancel();
  1845         iBackLightTimer->Cancel();
  1760     }
  1846     }
       
  1847     
  1761 }
  1848 }
  1762 
  1849 
  1763 //  ------------------------------------------------------------------------------------------------
  1850 //  ------------------------------------------------------------------------------------------------
  1764 //    CMPXVideoPlaybackState::StartBackLightTimer
  1851 //    CMPXVideoPlaybackState::StartBackLightTimer
  1765 //  ------------------------------------------------------------------------------------------------
  1852 //  ------------------------------------------------------------------------------------------------
  1770     if ( !iBackLightTimer->IsActive() )
  1857     if ( !iBackLightTimer->IsActive() )
  1771     {
  1858     {
  1772         iBackLightTimer->Start(
  1859         iBackLightTimer->Start(
  1773             0,
  1860             0,
  1774             KMPXBackLightTimeOut,
  1861             KMPXBackLightTimeOut,
  1775             TCallBack( CMPXVideoPlaybackController::HandleBackLightTimout, this ));
  1862             TCallBack( CMPXVideoPlaybackController::HandleBackLightTimeout, this ));
  1776     }
  1863     }
       
  1864     
  1777 }
  1865 }
  1778 
  1866 
  1779 // -------------------------------------------------------------------------------------------------
  1867 // -------------------------------------------------------------------------------------------------
  1780 // Handle back light timer timeout callback
  1868 // Handle back light timer timeout callback
  1781 // -------------------------------------------------------------------------------------------------
  1869 // -------------------------------------------------------------------------------------------------
  1782 //
  1870 //
  1783 TInt CMPXVideoPlaybackController::HandleBackLightTimout( TAny* aPtr )
  1871 TInt CMPXVideoPlaybackController::HandleBackLightTimeout( TAny* aPtr )
  1784 {
  1872 {
  1785     static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleBackLightTimout();
  1873     static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleBackLightTimeout();
  1786     return KErrNone;
  1874     return KErrNone;
  1787 }
  1875 }
  1788 
  1876 
  1789 // -------------------------------------------------------------------------------------------------
  1877 // -------------------------------------------------------------------------------------------------
  1790 // Handle back light timer timeout
  1878 // Handle back light timer timeout
  1791 // -------------------------------------------------------------------------------------------------
  1879 // -------------------------------------------------------------------------------------------------
  1792 //
  1880 //
  1793 void CMPXVideoPlaybackController::DoHandleBackLightTimout()
  1881 void CMPXVideoPlaybackController::DoHandleBackLightTimeout()
  1794 {
  1882 {
  1795     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleBackLightTimout()"));
  1883     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleBackLightTimeout()"));
  1796 
  1884     
       
  1885     TBool tvOutConnected( EFalse );
       
  1886     if ( iAccessoryMonitor )
       
  1887     {
       
  1888         tvOutConnected = iAccessoryMonitor->IsTvOutConnected();
       
  1889     }
       
  1890     
       
  1891     // User activity timer runs always when TV-out is connected
       
  1892     // it keeps resetting display timer and keeps lights on whenever there is user activity
       
  1893     if ( tvOutConnected )
       
  1894     {
       
  1895         MPX_DEBUG ( _L("CMPXVideoPlaybackController::DoHandleBackLightTimeout() inactivity time = %d"), User::InactivityTime().Int() );
       
  1896         // Cancel activity timer. Otherwise resetting inactivity time would fire user activity detection
       
  1897         CancelUserActivityTimer();
       
  1898     }
       
  1899         
  1797     User::ResetInactivityTime();
  1900     User::ResetInactivityTime();
       
  1901     
       
  1902     if ( tvOutConnected )
       
  1903     {
       
  1904         // Restart user activity timer. It must be running between backlight timer intervals so that backlight
       
  1905         // can be turned on if user activity is detected.
       
  1906         RestartUserActivityTimer();
       
  1907     }
       
  1908 }
       
  1909 
       
  1910 // -----------------------------------------------------------------------------
       
  1911 // CMPXVideoPlaybackController::StartLightsControl
       
  1912 // -----------------------------------------------------------------------------
       
  1913 //
       
  1914 void CMPXVideoPlaybackController::StartLightsControl()
       
  1915 {
       
  1916     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::StartLightsControl()"));
       
  1917 
       
  1918     StartBackLightTimer();
       
  1919              
       
  1920     if (iAccessoryMonitor )
       
  1921     {
       
  1922         if ( iAccessoryMonitor->IsTvOutConnected() )
       
  1923         {
       
  1924             RestartDisplayTimer();
       
  1925         }
       
  1926     }
       
  1927 }
       
  1928 
       
  1929 // -----------------------------------------------------------------------------
       
  1930 // CMPXVideoPlaybackController::CancelLightsControl
       
  1931 // -----------------------------------------------------------------------------
       
  1932 //
       
  1933 void CMPXVideoPlaybackController::CancelLightsControl()
       
  1934 {
       
  1935     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelLightsControl()"));
       
  1936 	
       
  1937     // This is called whenever there is no need to keep screensaver of anymore
       
  1938     // This means that also displaytimer and activity monitoring can be stopped. 
       
  1939     // This method is not correct place for these calls
       
  1940     CancelBackLightTimer();
       
  1941    
       
  1942     CancelUserActivityTimer();
       
  1943     
       
  1944     CancelDisplayTimer();
       
  1945 	
       
  1946     // Ensure that lights are on
       
  1947     EnableDisplayBacklight();
       
  1948     
       
  1949 	// Release lights if releserved
       
  1950     ReleaseLights();  
       
  1951 }
       
  1952 
       
  1953 
       
  1954 // -----------------------------------------------------------------------------
       
  1955 // CMPXVideoPlaybackController::InitDisplayTimerL
       
  1956 // -----------------------------------------------------------------------------
       
  1957 //
       
  1958 TTimeIntervalMicroSeconds32 CMPXVideoPlaybackController::InitDisplayTimerL()
       
  1959 {
       
  1960     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitDisplayTimerL()"));
       
  1961 	
       
  1962     if ( !iDisplayTimer )
       
  1963     {
       
  1964         iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard );
       
  1965 		
       
  1966         MPX_DEBUG(_L("CMPXVideoPlaybackController::InitDisplayTimerL() - created") );	
       
  1967         
       
  1968     }
       
  1969    
       
  1970     if ( iDisplayTimerTimeout.Int() == 0 )
       
  1971     {
       
  1972         // Get the display light time-out value from CenRep
       
  1973         CRepository* repository = CRepository::NewLC( KCRUidLightSettings  );    
       
  1974         // What's the timeout value (in seconds ) for the display light?
       
  1975         TInt displayTimeOut ( 0 );
       
  1976         repository->Get( KDisplayLightsTimeout, displayTimeOut );
       
  1977         
       
  1978         if ( ( displayTimeOut * KMPXMicroSecondsInASecond ) > KMaxTInt )
       
  1979         {
       
  1980             iDisplayTimerTimeout = KMaxTInt;
       
  1981         }
       
  1982         else
       
  1983         {
       
  1984             iDisplayTimerTimeout = displayTimeOut * KMPXMicroSecondsInASecond;
       
  1985         }
       
  1986         
       
  1987         CleanupStack::PopAndDestroy( repository );
       
  1988     }     
       
  1989     
       
  1990     
       
  1991     MPX_DEBUG( _L("CMPXVideoPlaybackController::InitDisplayTimerL Timeout(%d)"), iDisplayTimerTimeout.Int() );
       
  1992 	
       
  1993     // Convert the timeout value to microseconds
       
  1994     return iDisplayTimerTimeout;   
       
  1995 }
       
  1996 
       
  1997 // -----------------------------------------------------------------------------
       
  1998 // CMPXVideoPlaybackController::RestartDisplayTimer
       
  1999 // -----------------------------------------------------------------------------
       
  2000 //
       
  2001 void CMPXVideoPlaybackController::RestartDisplayTimer()
       
  2002 {
       
  2003     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::RestartDisplayTimer"));
       
  2004 
       
  2005     TTimeIntervalMicroSeconds32 displayTimeOut(0);
       
  2006     // Leave system to safe state if following leaves. Lights stay on
       
  2007     MPX_TRAPD(err, displayTimeOut=InitDisplayTimerL(); )
       
  2008     if ( err == KErrNone )
       
  2009     {   
       
  2010         // check if the display timer is running and cancel it
       
  2011         if ( iDisplayTimer->IsActive() )
       
  2012         {
       
  2013             iDisplayTimer->Cancel();
       
  2014         }
       
  2015       
       
  2016         MPX_DEBUG( _L("CMPXVideoPlaybackController::RestartDisplayTimer() restarting displayTimer to=%d ms"), displayTimeOut.Int() );
       
  2017         
       
  2018         iDisplayTimer->Start( displayTimeOut, displayTimeOut,
       
  2019             TCallBack( CMPXVideoPlaybackController::HandleDisplayTimeout, this ) );
       
  2020     }
       
  2021     
       
  2022 }
       
  2023 
       
  2024 // -----------------------------------------------------------------------------
       
  2025 // CMPXVideoPlaybackController::CancelDisplayTimer
       
  2026 // -----------------------------------------------------------------------------
       
  2027 //
       
  2028 void CMPXVideoPlaybackController::CancelDisplayTimer() 
       
  2029 {
       
  2030     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelDisplayTimer"));
       
  2031     
       
  2032     if ( iDisplayTimer )
       
  2033     {
       
  2034         if ( iDisplayTimer->IsActive() )
       
  2035         {
       
  2036             iDisplayTimer->Cancel();
       
  2037         }
       
  2038         delete iDisplayTimer;
       
  2039         iDisplayTimer = NULL;
       
  2040     }
       
  2041 }
       
  2042 
       
  2043 // -------------------------------------------------------------------------------------------------
       
  2044 //   CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout
       
  2045 // -------------------------------------------------------------------------------------------------
       
  2046 //
       
  2047 TInt CMPXVideoPlaybackController::HandleDisplayTimeout( TAny* aPtr )
       
  2048 {
       
  2049     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleDisplayTimeout"));
       
  2050 
       
  2051     static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleDisplayTimeout();
       
  2052 
       
  2053     return KErrNone;
       
  2054 }
       
  2055 
       
  2056 // -------------------------------------------------------------------------------------------------
       
  2057 //   CMPXVideoPlaybackUserInputHandler::DoHandleDisplayTimeout
       
  2058 // -------------------------------------------------------------------------------------------------
       
  2059 //
       
  2060 void CMPXVideoPlaybackController::DoHandleDisplayTimeout( )
       
  2061 {
       
  2062     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleDisplayTimeout"));
       
  2063 
       
  2064     DisableDisplayBacklight();
       
  2065     // Avoid missing user activity immediately after lights are turned off
       
  2066     RestartUserActivityTimer();
       
  2067 }
       
  2068 
       
  2069 
       
  2070 
       
  2071 //  ------------------------------------------------------------------------------------------------
       
  2072 //  CMPXVideoPlaybackController::EnableDisplayBacklight
       
  2073 //  ------------------------------------------------------------------------------------------------
       
  2074 // 
       
  2075 void CMPXVideoPlaybackController::EnableDisplayBacklight()
       
  2076 {
       
  2077     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::EnableDisplayBacklight()"));
       
  2078     
       
  2079     // ELightStatusUnknown - We are not controlling lights and we don't care about lights
       
  2080     // ELightOn            - Ligths are certainly on 
       
  2081     MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() iLightStatus=%d"), iLightStatus );
       
  2082     
       
  2083     // We are responsible of turning lights on only if we have switched them off.
       
  2084     if ( iLightStatus == CHWRMLight::ELightOff )
       
  2085     {
       
  2086 
       
  2087         MPX_TRAPD( err,
       
  2088         {   
       
  2089             // Following GetLightsL() call will not leave.
       
  2090             // This call should not result to creation of CHWRMLight in this case
       
  2091             // because CHWRMLight was created when lights were turned off.
       
  2092             CHWRMLight* lights= GetLightsL();
       
  2093             if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOff )
       
  2094             {
       
  2095                 MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() enabling") );
       
  2096 			
       
  2097                 lights->LightOnL( CHWRMLight::EPrimaryDisplay, 0  );
       
  2098                 iLightStatus = CHWRMLight::ELightOn;
       
  2099             }
       
  2100         } );
       
  2101         
       
  2102     }
       
  2103    
       
  2104 }
       
  2105 
       
  2106 //  ------------------------------------------------------------------------------------------------
       
  2107 //  CMPXVideoPlaybackController::DisableDisplayBacklight
       
  2108 //  ------------------------------------------------------------------------------------------------
       
  2109 // 
       
  2110 void CMPXVideoPlaybackController::DisableDisplayBacklight()
       
  2111 {
       
  2112     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DisableDisplayBacklight()"));
       
  2113        
       
  2114     // No major harm done if following block leaves. Lights are left on
       
  2115     MPX_TRAPD( err,
       
  2116     {  
       
  2117         CHWRMLight* lights = GetLightsL();
       
  2118         if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOn )
       
  2119         {
       
  2120            MPX_DEBUG(_L("CMPXVideoPlaybackController::DisableDisplayBacklight() disabling") );
       
  2121 		   
       
  2122            lights->LightOffL( CHWRMLight::EPrimaryDisplay, 0  );
       
  2123            iLightStatus = CHWRMLight::ELightOff;
       
  2124         }
       
  2125     } );
       
  2126    
       
  2127 }
       
  2128 
       
  2129 
       
  2130 //  ------------------------------------------------------------------------------------------------
       
  2131 //  CMPXVideoPlaybackController::InitUserActivityTimer
       
  2132 //  ------------------------------------------------------------------------------------------------
       
  2133 // 
       
  2134 void CMPXVideoPlaybackController::InitUserActivityTimerL()
       
  2135 {
       
  2136     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitUserActivityTimerL()"));
       
  2137     
       
  2138     iUserActivityTimer = CPeriodic::NewL( CActive::EPriorityStandard);
       
  2139     
       
  2140     // This timer will not run to the end. Timer will be canceled and reset at backlight timeout.    
       
  2141     iUserActivityTimer->Start(
       
  2142         0,
       
  2143         KMPXInactivityTimeout,
       
  2144         TCallBack( CMPXVideoPlaybackController::HandleUserActivityTimeout, this ));
       
  2145     
       
  2146 }
       
  2147 
       
  2148 //  ------------------------------------------------------------------------------------------------
       
  2149 //  CMPXVideoPlaybackController::RestartUserActivityTimer
       
  2150 //  ------------------------------------------------------------------------------------------------
       
  2151 // 
       
  2152 void CMPXVideoPlaybackController::RestartUserActivityTimer() 
       
  2153 {
       
  2154     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::RestartUserActivityTimer()"));
       
  2155     
       
  2156     if ( !iUserActivityTimer )
       
  2157     {
       
  2158        // This is first call. Create and initialize timer
       
  2159        MPX_TRAPD( err,
       
  2160        {   
       
  2161            InitUserActivityTimerL();
       
  2162        } );
       
  2163        // If user activity timer creation fails we can't detect user activity and 
       
  2164        // get lights back on when user taps screen. 
       
  2165        // Leave lights on.
       
  2166        if ( err != KErrNone )
       
  2167        { 
       
  2168            EnableDisplayBacklight(); 
       
  2169        }  
       
  2170     }
       
  2171       
       
  2172     if ( iUserActivityTimer )
       
  2173     {
       
  2174         if ( iUserActivityTimer->IsActive() )
       
  2175         {
       
  2176             iUserActivityTimer->Cancel();
       
  2177         }            
       
  2178         // Not interested about inactivity callback, only activity
       
  2179         // If CPeriodic::Inactivity is started with argument 0 
       
  2180         // timer will fire when system's user inactivity timer resets.
       
  2181         iUserActivityTimer->Inactivity( 0 );
       
  2182     } 
       
  2183 }
       
  2184 
       
  2185 //  ------------------------------------------------------------------------------------------------
       
  2186 //  CMPXVideoPlaybackController::CancelUserActivityTimer
       
  2187 //  ------------------------------------------------------------------------------------------------
       
  2188 // 
       
  2189 void CMPXVideoPlaybackController::CancelUserActivityTimer() 
       
  2190 {
       
  2191     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelUserActivityTimer()"));
       
  2192 	
       
  2193     if  ( iUserActivityTimer ) 
       
  2194     {   
       
  2195         if ( iUserActivityTimer->IsActive() )
       
  2196         {
       
  2197             iUserActivityTimer->Cancel();
       
  2198         }
       
  2199     }
       
  2200 }
       
  2201 
       
  2202 //  ------------------------------------------------------------------------------------------------
       
  2203 //  CMPXVideoPlaybackController::HandleUserActivityTimeout
       
  2204 //  ------------------------------------------------------------------------------------------------
       
  2205 // 
       
  2206 TInt CMPXVideoPlaybackController::HandleUserActivityTimeout( TAny* aPtr )
       
  2207 {
       
  2208     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleUserActivityTimeout()"));
       
  2209 	
       
  2210     static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleUserActivityTimeout();
       
  2211     return KErrNone;     
       
  2212 }
       
  2213 
       
  2214 //  ------------------------------------------------------------------------------------------------
       
  2215 //  CMPXVideoPlaybackController::DoHandleUserActivityTimeout
       
  2216 //  ------------------------------------------------------------------------------------------------
       
  2217 // 
       
  2218 void CMPXVideoPlaybackController::DoHandleUserActivityTimeout()
       
  2219 {
       
  2220     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleUserActivityTimeout()"));
       
  2221     
       
  2222     // Act only once for detected activity.
       
  2223     if ( iUserActivityTimer->IsActive() ) 
       
  2224     {
       
  2225         iUserActivityTimer->Cancel();
       
  2226     }
       
  2227     
       
  2228     // iUserActivityTimer runs when TV-out is connected and playback with video is going on
       
  2229     // This timer fires in two situations. 
       
  2230     // a) Lights are off and user activity is detected - Turn lights on and restart display timer
       
  2231     // b) Lights are on and user activity is detected - restart display timer to prevent lights go off
       
  2232     EnableDisplayBacklight();
       
  2233     
       
  2234     // Start counting down to next lights off
       
  2235     RestartDisplayTimer();
       
  2236 }
       
  2237 
       
  2238 //  ------------------------------------------------------------------------------------------------
       
  2239 //  CMPXVideoPlaybackController::GetLightsL
       
  2240 //  ------------------------------------------------------------------------------------------------
       
  2241 //
       
  2242 CHWRMLight* CMPXVideoPlaybackController::GetLightsL()
       
  2243 {
       
  2244     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::GetLightsL()"));
       
  2245 	
       
  2246     if ( !iLight ) 
       
  2247     {
       
  2248         MPX_DEBUG( _L("CMPXVideoPlaybackController::GetLightsL() - creating") );
       
  2249         iLight = CHWRMLight::NewL();
       
  2250     }
       
  2251     return iLight;
       
  2252 }
       
  2253 
       
  2254 //  ------------------------------------------------------------------------------------------------
       
  2255 //  CMPXVideoPlaybackController::ReleaseLights
       
  2256 //  ------------------------------------------------------------------------------------------------
       
  2257 //
       
  2258 void CMPXVideoPlaybackController::ReleaseLights()
       
  2259 {
       
  2260     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::ReleaseLights()"));
       
  2261 	
       
  2262     if ( iLight )
       
  2263     {
       
  2264         // If iLights was created when ReleaseLights was called then TV out must be connected and lights may be off. 
       
  2265         // This call ensures that lights are on again.
       
  2266         EnableDisplayBacklight();
       
  2267 		
       
  2268         MPX_DEBUG( _L("CMPXVideoPlaybackController::ReleaseLights() - deleting") );
       
  2269         delete iLight;
       
  2270         iLight = NULL;
       
  2271     }
  1798 }
  2272 }
  1799 
  2273 
  1800 // -------------------------------------------------------------------------------------------------
  2274 // -------------------------------------------------------------------------------------------------
  1801 // CMPXVideoPlaybackController::InitVolumeWatchers()
  2275 // CMPXVideoPlaybackController::InitVolumeWatchers()
  1802 // -------------------------------------------------------------------------------------------------
  2276 // -------------------------------------------------------------------------------------------------
  1803 //
  2277 //
  1804 void CMPXVideoPlaybackController::InitVolumeWatchers()
  2278 void CMPXVideoPlaybackController::InitVolumeWatchersL()
  1805 {
  2279 {
  1806     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitVolumeWatchers()"));
  2280     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitVolumeWatchers()"));
  1807 
  2281 
  1808     if ( ! iVolumeWatcher )
  2282     if ( ! iVolumeWatcher )
  1809     {
  2283     {
  1810         MPX_TRAPD( err,
  2284         iVolumeWatcher = CMPXCenRepWatcher::NewL( KCRUidMPXVideoSettings,
  1811                 iVolumeWatcher = CMPXCenRepWatcher::NewL( KCRUidMPXVideoSettings,
  2285                                                   KMPXVideoPlaybackVolume,
  1812                                                           KMPXVideoPlaybackVolume,
  2286                                                   this );
  1813                                                           this ) );
       
  1814     }
  2287     }
  1815 
  2288 
  1816     if ( ! iMuteWatcher )
  2289     if ( ! iMuteWatcher )
  1817     {
  2290     {
  1818         MPX_TRAPD( err,
  2291         iMuteWatcher = CMPXCenRepWatcher::NewL( KCRUidMPXVideoSettings,
  1819                 iMuteWatcher = CMPXCenRepWatcher::NewL( KCRUidMPXVideoSettings,
  2292                                                 KMPXVideoPlaybackMute,
  1820                                                         KMPXVideoPlaybackMute,
  2293                                                 this );
  1821                                                         this ) );
       
  1822     }
  2294     }
  1823 
  2295 
  1824     //
  2296     //
  1825     // MPX framework volume range : 0-100
  2297     // MPX framework volume range : 0-100
  1826     // Media player volume range : 0-10
  2298     // Media player volume range : 0-10
  1866 {
  2338 {
  1867     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::ResetMemberVariables()"));
  2339     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::ResetMemberVariables()"));
  1868 
  2340 
  1869     iPlayer->Reset();
  2341     iPlayer->Reset();
  1870 
  2342 
       
  2343     //
       
  2344     // Delete the video accessory observer when the plugin
       
  2345     // goes back to Not Initialised state.
       
  2346     //
       
  2347     if ( iAccessoryMonitor )
       
  2348     {
       
  2349         delete iAccessoryMonitor;
       
  2350         iAccessoryMonitor = NULL;
       
  2351     }
       
  2352 
  1871     if ( iFileDetails )
  2353     if ( iFileDetails )
  1872     {
  2354     {
  1873         delete iFileDetails;
  2355         delete iFileDetails;
  1874         iFileDetails = NULL;
  2356         iFileDetails = NULL;
  1875     }
  2357     }
  1910 
  2392 
  1911     //
  2393     //
  1912     //  Reset the flag to retrieve the Buffering percentage from Helix
  2394     //  Reset the flag to retrieve the Buffering percentage from Helix
  1913     //
  2395     //
  1914     iHelixLoadingStarted = EFalse;
  2396     iHelixLoadingStarted = EFalse;
       
  2397 
       
  2398     iSavedPosition = 0;
  1915 }
  2399 }
  1916 
  2400 
  1917 //  ------------------------------------------------------------------------------------------------
  2401 //  ------------------------------------------------------------------------------------------------
  1918 //  CMPXVideoPlaybackController::HandleVolumeL
  2402 //  CMPXVideoPlaybackController::HandleVolumeL
  1919 //  ------------------------------------------------------------------------------------------------
  2403 //  ------------------------------------------------------------------------------------------------
  1967 //    CMPXVideoPlaybackController::OpenFile64L()
  2451 //    CMPXVideoPlaybackController::OpenFile64L()
  1968 //  ------------------------------------------------------------------------------------------------
  2452 //  ------------------------------------------------------------------------------------------------
  1969 //
  2453 //
  1970 void CMPXVideoPlaybackController::OpenFile64L( const TDesC& aMediaFile,
  2454 void CMPXVideoPlaybackController::OpenFile64L( const TDesC& aMediaFile,
  1971                                                RFile64& aFile,
  2455                                                RFile64& aFile,
       
  2456                                                TInt aPosition,
  1972                                                TInt aAccessPointId )
  2457                                                TInt aAccessPointId )
  1973 {
  2458 {
  1974     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::OpenFile64L( RFile64 )"),
  2459     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::OpenFile64L( RFile64 )"),
  1975                    _L("file = %S"), &aMediaFile );
  2460                    _L("file = %S, position = %d"), &aMediaFile, aPosition );
  1976 
  2461 
  1977     TBool fileExists = EFalse;
  2462     TBool fileExists = EFalse;
  1978 
  2463 
  1979     ChangeState( EMPXVideoInitializing );
  2464     ChangeState( EMPXVideoInitializing );
  1980 
  2465 
  1997     }
  2482     }
  1998 
  2483 
  1999     DetermineMediaTypeL();
  2484     DetermineMediaTypeL();
  2000     SetPlaybackModeL();
  2485     SetPlaybackModeL();
  2001 
  2486 
       
  2487     iSavedPosition = aPosition; 
       
  2488     
  2002     //
  2489     //
  2003     //  Create accessory monitor to search for TV-Out events
  2490     //  Create accessory monitor to search for TV-Out events
  2004     //
  2491     //
  2005     if ( ! iAccessoryMonitor )
  2492     if ( ! iAccessoryMonitor )
  2006     {
  2493     {