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