videoplayback/videoplaybackview/viewsrc/videoplaybackuserinputhandler.cpp
changeset 55 4bfa887905cf
child 58 d2b028fd1f7d
equal deleted inserted replaced
50:21fe8338c6bf 55:4bfa887905cf
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of playback view's input handler
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 9 %
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32std.h>
       
    23 #include <w32std.h> // RWindowBase
       
    24 #include <e32base.h>
       
    25 #include <eikclbd.h>
       
    26 #include <aknconsts.h>
       
    27 #include <remconcoreapi.h>
       
    28 #include <remconcoreapitarget.h>
       
    29 #include <remconinterfaceselector.h> // Side volume key
       
    30 #include <mpxplaybackframeworkdefs.h>
       
    31 #include <centralrepository.h>  // for peripheral display timeout setting
       
    32 #include <settingsinternalcrkeys.h> // display timeout setting keys
       
    33 #include <hwrmlightdomaincrkeys.h>
       
    34 #include <mpxvideoplaybackdefs.h>
       
    35 
       
    36 #include <hal.h>
       
    37 #include <hal_data.h>
       
    38 
       
    39 #include "mpxvideo_debug.h"
       
    40 #include "mpxvideoviewwrapper.h"
       
    41 #include "mpxcommonvideoplaybackview.hrh"
       
    42 #include "videoplaybackuserinputhandler.h"
       
    43 
       
    44 
       
    45 // CONSTANTS
       
    46 const TInt KMPXMicroSecondsInASecond = 1000000;
       
    47 
       
    48 
       
    49 // ======== MEMBER FUNCTIONS =======================================================================
       
    50 
       
    51 // -------------------------------------------------------------------------------------------------
       
    52 // CVideoPlaybackUserInputHandler::CVideoPlaybackUserInputHandler()
       
    53 // -------------------------------------------------------------------------------------------------
       
    54 //
       
    55 CVideoPlaybackUserInputHandler::CVideoPlaybackUserInputHandler( CMPXVideoViewWrapper* aWrapper )
       
    56    : iViewWrapper( aWrapper )
       
    57 {
       
    58 }
       
    59 
       
    60 // -------------------------------------------------------------------------------------------------
       
    61 // CVideoPlaybackUserInputHandler::NewL()
       
    62 // -------------------------------------------------------------------------------------------------
       
    63 //
       
    64 CVideoPlaybackUserInputHandler* CVideoPlaybackUserInputHandler::NewL(
       
    65         CMPXVideoViewWrapper* aWrapper, TBool aTvOutConnected )
       
    66 {
       
    67     MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::NewL()"));
       
    68 
       
    69     CVideoPlaybackUserInputHandler* self =
       
    70         new (ELeave) CVideoPlaybackUserInputHandler( aWrapper );
       
    71     CleanupStack::PushL( self );
       
    72     self->ConstructL( aTvOutConnected );
       
    73     CleanupStack::Pop();
       
    74     return self;
       
    75 }
       
    76 
       
    77 // -------------------------------------------------------------------------------------------------
       
    78 // CVideoPlaybackUserInputHandler::ConstructL
       
    79 // Symbian 2nd phase constructor can leave.
       
    80 // -------------------------------------------------------------------------------------------------
       
    81 //
       
    82 void CVideoPlaybackUserInputHandler::ConstructL( TBool aTvOutConnected )
       
    83 {
       
    84     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::ConstructL()"));
       
    85 
       
    86     iVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    87     iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard );
       
    88     iInterfaceSelector = CRemConInterfaceSelector::NewL();
       
    89     iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this );
       
    90 
       
    91     iTVOutConnected = aTvOutConnected;
       
    92  
       
    93     // Start the timer if TV out is connected
       
    94     if ( iTVOutConnected )
       
    95     {                
       
    96         // Get the display light time-out value from CenRep 
       
    97         CRepository* repository = CRepository::NewLC( KCRUidLightSettings  );
       
    98     
       
    99         // What's the timeout value (in seconds ) for the display light?
       
   100         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   101         MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   102     
       
   103         CleanupStack::PopAndDestroy( repository );
       
   104     
       
   105         // Convert the timeout value to microseconds
       
   106         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   107     
       
   108         RestartDisplayTimer();
       
   109     }
       
   110 
       
   111     // not detrimental if Media Keys dont work - so ignore any errors here
       
   112     TRAP_IGNORE( iInterfaceSelector->OpenTargetL() );
       
   113 
       
   114     iProcessingInputType = EVideoNone;
       
   115     iForeground = ETrue;
       
   116 }
       
   117 
       
   118 // -------------------------------------------------------------------------------------------------
       
   119 // CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()
       
   120 // -------------------------------------------------------------------------------------------------
       
   121 //
       
   122 CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()
       
   123 {
       
   124     if ( iVolumeRepeatTimer )
       
   125     {
       
   126         iVolumeRepeatTimer->Cancel();
       
   127         delete iVolumeRepeatTimer;
       
   128     }
       
   129 
       
   130     if ( iDisplayTimer )
       
   131     {
       
   132         iDisplayTimer->Cancel();
       
   133         delete iDisplayTimer;
       
   134     }
       
   135 
       
   136     if ( iInterfaceSelector )
       
   137     {
       
   138         delete iInterfaceSelector;
       
   139         iCoreTarget = NULL;
       
   140         iInterfaceSelector = NULL;
       
   141     }
       
   142 
       
   143     // make sure that backlight enabled when 
       
   144     // the view updates or deactivates
       
   145     EnableBacklight();
       
   146 }
       
   147 
       
   148 // -------------------------------------------------------------------------------------------------
       
   149 // CVideoPlaybackUserInputHandler::MrccatoPlay()
       
   150 // -------------------------------------------------------------------------------------------------
       
   151 //
       
   152 void CVideoPlaybackUserInputHandler::MrccatoPlay( TRemConCoreApiPlaybackSpeed /*aSpeed*/,
       
   153                                                   TRemConCoreApiButtonAction aButtonAct )
       
   154 {
       
   155     MPX_ENTER_EXIT(
       
   156         _L("CVideoPlaybackUserInputHandler::MrccatoPlay"),
       
   157         _L("aButtonAct = %d"), aButtonAct );
       
   158 
       
   159     ProcessMediaKey(ERemConCoreApiPlay, aButtonAct);
       
   160 }
       
   161 
       
   162 // -------------------------------------------------------------------------------------------------
       
   163 // CVideoPlaybackUserInputHandler::MrccatoCommand()
       
   164 // -------------------------------------------------------------------------------------------------
       
   165 //
       
   166 void CVideoPlaybackUserInputHandler::MrccatoCommand( TRemConCoreApiOperationId aOperationId,
       
   167                                                      TRemConCoreApiButtonAction aButtonAct )
       
   168 {
       
   169     MPX_ENTER_EXIT(
       
   170         _L("CVideoPlaybackUserInputHandler::MrccatoCommand"),
       
   171         _L("aButtonAct = %d"), aButtonAct );
       
   172 
       
   173     ProcessMediaKey(aOperationId, aButtonAct);
       
   174 }
       
   175 
       
   176 
       
   177 // -------------------------------------------------------------------------------------------------
       
   178 // CVideoPlaybackUserInputHandler::DoHandleMediaKey()
       
   179 // -------------------------------------------------------------------------------------------------
       
   180 //
       
   181 void CVideoPlaybackUserInputHandler::DoHandleMediaKey( TRemConCoreApiOperationId aOperationId,
       
   182                                                        TRemConCoreApiButtonAction aButtonAct )
       
   183 {
       
   184     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DoHandleMediaKey()"));
       
   185 
       
   186     switch ( aOperationId )
       
   187     {
       
   188         case ERemConCoreApiStop:
       
   189         {
       
   190             if ( aButtonAct == ERemConCoreApiButtonClick )
       
   191             {
       
   192                 TRAP_IGNORE(iViewWrapper->HandleCommandL( EMPXPbvCmdStop ));
       
   193             }
       
   194             break;
       
   195         }
       
   196         case ERemConCoreApiRewind:
       
   197         {
       
   198             HandleRewind(aButtonAct);
       
   199             break;
       
   200         }
       
   201         case ERemConCoreApiFastForward:
       
   202         {
       
   203             HandleFastForward(aButtonAct);
       
   204             break;
       
   205         }
       
   206         case ERemConCoreApiVolumeUp:
       
   207         {
       
   208             HandleVolumeUp(aButtonAct);
       
   209             break;
       
   210         }
       
   211         case ERemConCoreApiVolumeDown:
       
   212         {
       
   213             HandleVolumeDown(aButtonAct);
       
   214             break;
       
   215         }
       
   216         case ERemConCoreApiPausePlayFunction:
       
   217         {
       
   218             if ( aButtonAct == ERemConCoreApiButtonClick )
       
   219             {
       
   220                 TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPlayPause));
       
   221             }
       
   222             break;
       
   223         }
       
   224         case ERemConCoreApiPause:
       
   225         {
       
   226             TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPause));
       
   227             break;
       
   228         }
       
   229         case ERemConCoreApiPlay:
       
   230         {
       
   231             if ( aButtonAct == ERemConCoreApiButtonClick )
       
   232             {
       
   233                 TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPlay));
       
   234             }
       
   235             break;
       
   236         }
       
   237         default:
       
   238             break;
       
   239     }
       
   240 }
       
   241 
       
   242 // -------------------------------------------------------------------------------------------------
       
   243 // CVideoPlaybackUserInputHandler::HandleFastForward()
       
   244 // -------------------------------------------------------------------------------------------------
       
   245 //
       
   246 void CVideoPlaybackUserInputHandler::HandleFastForward( TRemConCoreApiButtonAction aButtonAct )
       
   247 {
       
   248     if (aButtonAct == ERemConCoreApiButtonPress)
       
   249     {
       
   250         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdSeekForward));
       
   251     }
       
   252     else if (aButtonAct == ERemConCoreApiButtonRelease)
       
   253     {
       
   254         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdEndSeek));
       
   255     }
       
   256 }
       
   257 
       
   258 
       
   259 // -------------------------------------------------------------------------------------------------
       
   260 // CVideoPlaybackUserInputHandler::HandleRewind()
       
   261 // -------------------------------------------------------------------------------------------------
       
   262 //
       
   263 void CVideoPlaybackUserInputHandler::HandleRewind( TRemConCoreApiButtonAction aButtonAct )
       
   264 {
       
   265     if (aButtonAct == ERemConCoreApiButtonPress)
       
   266     {
       
   267         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdSeekBackward));
       
   268     }
       
   269     else if (aButtonAct == ERemConCoreApiButtonRelease)
       
   270     {
       
   271         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdEndSeek));
       
   272     }
       
   273 }
       
   274 
       
   275 // -------------------------------------------------------------------------------------------------
       
   276 // CVideoPlaybackUserInputHandler::HandleVolumeUp()
       
   277 // -------------------------------------------------------------------------------------------------
       
   278 //
       
   279 void CVideoPlaybackUserInputHandler::HandleVolumeUp( TRemConCoreApiButtonAction aButtonAct )
       
   280 {
       
   281     switch ( aButtonAct )
       
   282     {
       
   283         case ERemConCoreApiButtonPress:
       
   284         {
       
   285             // Volume Up - Pressed
       
   286             if ( iVolumeRepeatTimer->IsActive() )
       
   287             {
       
   288                 iVolumeRepeatTimer->Cancel();
       
   289             }
       
   290 
       
   291             iVolumeRepeatUp = ETrue;
       
   292             iVolumeRepeatTimer->Start(
       
   293                 KAknStandardKeyboardRepeatRate,
       
   294                 KAknStandardKeyboardRepeatRate,
       
   295                 TCallBack(
       
   296                     CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
       
   297                     this ) );
       
   298 
       
   299             break;
       
   300         }
       
   301         case ERemConCoreApiButtonRelease:
       
   302         {
       
   303             // Volume Up - Released
       
   304             iVolumeRepeatTimer->Cancel();
       
   305             break;
       
   306         }
       
   307         case ERemConCoreApiButtonClick:
       
   308         {
       
   309             // Volume Up - Clicked
       
   310             TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdIncreaseVolume ) );
       
   311             break;
       
   312         }
       
   313     }
       
   314 }
       
   315 
       
   316 
       
   317 // -------------------------------------------------------------------------------------------------
       
   318 // CVideoPlaybackUserInputHandler::HandleVolumeDown()
       
   319 // -------------------------------------------------------------------------------------------------
       
   320 //
       
   321 void CVideoPlaybackUserInputHandler::HandleVolumeDown( TRemConCoreApiButtonAction aButtonAct )
       
   322 {
       
   323     switch ( aButtonAct )
       
   324     {
       
   325         case ERemConCoreApiButtonPress:
       
   326         {
       
   327             // Volume Up - Pressed
       
   328             if ( iVolumeRepeatTimer->IsActive() )
       
   329             {
       
   330                 iVolumeRepeatTimer->Cancel();
       
   331             }
       
   332 
       
   333             iVolumeRepeatUp = EFalse;
       
   334             iVolumeRepeatTimer->Start(
       
   335                 KAknStandardKeyboardRepeatRate,
       
   336                 KAknStandardKeyboardRepeatRate,
       
   337                 TCallBack(
       
   338                     CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
       
   339                     this ) );
       
   340 
       
   341             break;
       
   342         }
       
   343         case ERemConCoreApiButtonRelease:
       
   344         {
       
   345             // Volume Up - Released
       
   346             iVolumeRepeatTimer->Cancel();
       
   347             break;
       
   348         }
       
   349         case ERemConCoreApiButtonClick:
       
   350         {
       
   351             // Volume Down - Clicked
       
   352             TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdDecreaseVolume ) );
       
   353             break;
       
   354         }
       
   355     }
       
   356 }
       
   357 
       
   358 // -------------------------------------------------------------------------------------------------
       
   359 // CVideoPlaybackUserInputHandler::ProcessKeyEvent()
       
   360 // -------------------------------------------------------------------------------------------------
       
   361 //
       
   362 void CVideoPlaybackUserInputHandler::ProcessKeyEventL( const TKeyEvent& /*aKeyEvent*/,
       
   363                                                        TEventCode /*aType*/ )
       
   364 {
       
   365     MPX_DEBUG(_L("VideoPlaybackUserInputHandler::ProcessKeyEvent"));
       
   366 
       
   367     /*
       
   368     switch (iProcessingInputType)
       
   369     {
       
   370         case EVideoNone:
       
   371         {
       
   372             if (aType == EEventKeyDown && iForeground)
       
   373             {
       
   374                 iProcessingInputType = EVideoKeyboard;
       
   375                 iLastPressedKeyCode = aKeyEvent.iCode;
       
   376                 iLastPressedKeyScanCode = aKeyEvent.iScanCode;
       
   377                 if ( iTVOutConnected )
       
   378                 {    
       
   379                     RestartDisplayTimer();
       
   380                 }
       
   381                 iViewWrapper->DoHandleKeyEventL( aKeyEvent, aType );
       
   382             }
       
   383             break;
       
   384         }
       
   385         case EVideoKeyboard:
       
   386         {
       
   387             if (aType == EEventKeyUp)
       
   388             {
       
   389                 // only handle up event for the key being handled
       
   390                 // ignore spurious key presses
       
   391                 if (aKeyEvent.iCode == iLastPressedKeyCode  &&
       
   392                     aKeyEvent.iScanCode == iLastPressedKeyScanCode)
       
   393                 {
       
   394                     iViewWrapper->DoHandleKeyEventL( aKeyEvent, aType );
       
   395 
       
   396                     // reset the value only on key up event
       
   397                     iProcessingInputType = EVideoNone;
       
   398                 }
       
   399             }
       
   400             break;
       
   401         }
       
   402         default:
       
   403         {
       
   404             // user input is disallowed
       
   405             break;
       
   406         }
       
   407     } // switch*/
       
   408 }
       
   409 
       
   410 // -------------------------------------------------------------------------------------------------
       
   411 // CVideoPlaybackUserInputHandler::ProcessMediaKey()
       
   412 // -------------------------------------------------------------------------------------------------
       
   413 //
       
   414 void CVideoPlaybackUserInputHandler::ProcessMediaKey( TRemConCoreApiOperationId aOperationId,
       
   415                                                       TRemConCoreApiButtonAction aButtonAct )
       
   416 {
       
   417     MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ProcessMediaKey"));
       
   418 
       
   419     switch (iProcessingInputType)
       
   420     {
       
   421         case EVideoNone:
       
   422         {
       
   423             if (aButtonAct == ERemConCoreApiButtonPress && iForeground)
       
   424             {
       
   425                 iProcessingInputType = EVideoMediaKeys;
       
   426                 iLastMediaKeyPressed = aOperationId;
       
   427                 DoHandleMediaKey(aOperationId, aButtonAct);
       
   428                 if ( iTVOutConnected )
       
   429                 {    
       
   430                     RestartDisplayTimer();
       
   431                 }
       
   432             }
       
   433             else if (aButtonAct == ERemConCoreApiButtonClick && iForeground)
       
   434             {
       
   435                 DoHandleMediaKey(aOperationId, aButtonAct);
       
   436                 if ( iTVOutConnected )
       
   437                 {    
       
   438                     RestartDisplayTimer();
       
   439                 }
       
   440                 // reset on click AND/OR release
       
   441                 iProcessingInputType = EVideoNone;
       
   442             }
       
   443             break;
       
   444         }
       
   445         case EVideoMediaKeys:
       
   446         {
       
   447             if (aButtonAct == ERemConCoreApiButtonRelease)
       
   448             {
       
   449                 // handle only if this release is for media-key being currently handled
       
   450                 // ignore spurious media key presses
       
   451                 if (iLastMediaKeyPressed == aOperationId)
       
   452                 {
       
   453                     DoHandleMediaKey(aOperationId, aButtonAct);
       
   454                     // reset on click AND/OR release
       
   455                     iProcessingInputType = EVideoNone;
       
   456                 }
       
   457             }
       
   458             break;
       
   459         }
       
   460         default:
       
   461         {
       
   462             // user input is disallowed
       
   463             break;
       
   464         }
       
   465     } // switch
       
   466 }
       
   467 
       
   468 
       
   469 // -------------------------------------------------------------------------------------------------
       
   470 //   CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL()
       
   471 // -------------------------------------------------------------------------------------------------
       
   472 //
       
   473 TInt CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL( TAny* aPtr )
       
   474 {
       
   475     MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL()"));
       
   476 
       
   477     static_cast<CVideoPlaybackUserInputHandler*>(aPtr)->HandleVolumeRepeatL();
       
   478 
       
   479     return KErrNone;
       
   480 }
       
   481 
       
   482 // -------------------------------------------------------------------------------------------------
       
   483 //   CVideoPlaybackUserInputHandler::HandleVolumeRepeatL()
       
   484 // -------------------------------------------------------------------------------------------------
       
   485 //
       
   486 void CVideoPlaybackUserInputHandler::HandleVolumeRepeatL()
       
   487 {
       
   488     MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::HandleVolumeRepeatL()"));
       
   489 
       
   490     TMPXVideoPlaybackViewCommandIds command = EMPXPbvCmdDecreaseVolume;
       
   491 
       
   492     if ( iVolumeRepeatUp )
       
   493     {
       
   494         command = EMPXPbvCmdIncreaseVolume;
       
   495     }
       
   496 
       
   497     iViewWrapper->HandleCommandL( command );
       
   498 }
       
   499 
       
   500 
       
   501 // -------------------------------------------------------------------------------------------------
       
   502 //   CVideoPlaybackUserInputHandler::SetForeground()
       
   503 // -------------------------------------------------------------------------------------------------
       
   504 //
       
   505 void CVideoPlaybackUserInputHandler::SetForeground( TBool aForeground )
       
   506 {
       
   507     iForeground = aForeground;
       
   508 
       
   509     if ( !iForeground )
       
   510     {
       
   511         // we are in background so reset iProcessingInputType value
       
   512         iProcessingInputType = EVideoNone;
       
   513     }
       
   514 }
       
   515 
       
   516 // -------------------------------------------------------------------------------------------------
       
   517 // CVideoPlaybackUserInputHandler::DisableBacklight()
       
   518 // -------------------------------------------------------------------------------------------------
       
   519 //
       
   520 void CVideoPlaybackUserInputHandler::DisableBacklight()
       
   521 {
       
   522     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DisableBacklight"));
       
   523     
       
   524     // cancel the timer
       
   525     iDisplayTimer->Cancel(); 
       
   526 
       
   527     // disable the backlight
       
   528     HAL::Set( HALData::EBacklightState, 0 );
       
   529 }
       
   530 
       
   531 // -------------------------------------------------------------------------------------------------
       
   532 // CVideoPlaybackUserInputHandler::EnableBacklight()
       
   533 // -------------------------------------------------------------------------------------------------
       
   534 //
       
   535 void CVideoPlaybackUserInputHandler::EnableBacklight()
       
   536 {
       
   537     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::EnableBacklight"));
       
   538  
       
   539     // enable the backlight
       
   540     HAL::Set( HALData::EBacklightState, 1 );    
       
   541 }
       
   542 
       
   543 
       
   544 // -------------------------------------------------------------------------------------------------
       
   545 //   CVideoPlaybackUserInputHandler::HandleTVOutEvent()
       
   546 // -------------------------------------------------------------------------------------------------
       
   547 //
       
   548 void CVideoPlaybackUserInputHandler::HandleTVOutEventL(TBool aTVOutConnected)
       
   549 {
       
   550     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleTVOutEvent"));
       
   551 
       
   552     iTVOutConnected = aTVOutConnected;
       
   553 
       
   554     if ( iTVOutConnected )
       
   555     {
       
   556         // Get the display light time-out value from CenRep 
       
   557         CRepository* repository = CRepository::NewLC( KCRUidLightSettings );
       
   558     
       
   559         // What's the timeout value (in seconds ) for the display light?
       
   560         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   561         MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   562     
       
   563         CleanupStack::PopAndDestroy( repository );
       
   564     
       
   565         // Convert the timeout value to microseconds
       
   566         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   567     
       
   568         RestartDisplayTimer();
       
   569     }
       
   570     else
       
   571     {
       
   572         iDisplayTimer->Cancel(); 
       
   573         EnableBacklight();
       
   574     }
       
   575 }
       
   576 
       
   577 // -------------------------------------------------------------------------------------------------
       
   578 //   CVideoPlaybackUserInputHandler::HandleDisplayTimeout
       
   579 // -------------------------------------------------------------------------------------------------
       
   580 //
       
   581 TInt CVideoPlaybackUserInputHandler::HandleDisplayTimeout( TAny* aPtr )
       
   582 {
       
   583     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleDisplayTimeout"));
       
   584 
       
   585     static_cast<CVideoPlaybackUserInputHandler*>(aPtr)->DisableBacklight();
       
   586 
       
   587     return KErrNone;
       
   588 }
       
   589 
       
   590 // -----------------------------------------------------------------------------
       
   591 // CVideoPlaybackUserInputHandler::RestartDisplayTimer
       
   592 // -----------------------------------------------------------------------------
       
   593 //
       
   594 void CVideoPlaybackUserInputHandler::RestartDisplayTimer()
       
   595 {
       
   596     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::RestartDisplayTimer"));
       
   597 
       
   598     // check if the display timer is running if so cancelit
       
   599     if ( iDisplayTimer->IsActive() )
       
   600     {
       
   601         iDisplayTimer->Cancel(); 
       
   602     }
       
   603     else
       
   604     {
       
   605         // timeout has happened and the backlight is disabled
       
   606         // enable the backlight
       
   607         HAL::Set( HALData::EBacklightState, 1 );    
       
   608     }
       
   609     
       
   610     TBool backlightState;    
       
   611     TInt ret = HAL::Get( HALData::EBacklightState, backlightState );    
       
   612 
       
   613     // Re start the display backlight timer
       
   614     iDisplayTimer->Start( iDisplayTimeOut, iDisplayTimeOut,
       
   615                           TCallBack( CVideoPlaybackUserInputHandler::HandleDisplayTimeout, this ) );                     
       
   616 }
       
   617 
       
   618 // EOF