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