videoplayback/hbvideoplaybackview/tsrc/testcontrolconfiguration/stub/inc/mpxvideoplaybackcontrolscontroller.h
author hgs
Thu, 01 Apr 2010 23:32:44 +0300
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 17 69946d1824c4
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) 2010 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 MPXVideoPlaybackControlsController
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// Version : %version:  1 %
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#ifndef MPXVIDEOPLAYBACKCONTROLSCONTROLLER_H_
hgs
parents:
diff changeset
    23
#define MPXVIDEOPLAYBACKCONTROLSCONTROLLER_H_
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
// INCLUDES
hgs
parents:
diff changeset
    26
#include <qobject>
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
#include <mpxplaybackframeworkdefs.h>
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
#include "mpxvideo_debug.h"
hgs
parents:
diff changeset
    31
#include "mpxvideoplaybackcontrol.hrh"
hgs
parents:
diff changeset
    32
#include "mpxcommonvideoplaybackview.hrh"
hgs
parents:
diff changeset
    33
#include "mpxvideoplaybackviewfiledetails.h"
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
// FORWARD DECLARATIONS
hgs
parents:
diff changeset
    36
class QTimer;
hgs
parents:
diff changeset
    37
class QString;
hgs
parents:
diff changeset
    38
class HbAction;
hgs
parents:
diff changeset
    39
class QActionGroup;
hgs
parents:
diff changeset
    40
class QMPXVideoPlaybackControlPolicy;
hgs
parents:
diff changeset
    41
class QMPXVideoPlaybackControlsLayout;
hgs
parents:
diff changeset
    42
class QMPXVideoPlaybackDocumentLoader;
hgs
parents:
diff changeset
    43
class QMPXVideoPlaybackFullScreenControl;
hgs
parents:
diff changeset
    44
class QMPXVideoPlaybackNonTouchVolumeBar;
hgs
parents:
diff changeset
    45
class QMPXVideoPlaybackControlsController;
hgs
parents:
diff changeset
    46
class QMPXVideoPlaybackControlConfiguration;
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
hgs
parents:
diff changeset
    49
// DATA TYPES
hgs
parents:
diff changeset
    50
hgs
parents:
diff changeset
    51
enum TMPXTimerAction
hgs
parents:
diff changeset
    52
{
hgs
parents:
diff changeset
    53
    EMPXTimerCancel,
hgs
parents:
diff changeset
    54
    EMPXTimerReset
hgs
parents:
diff changeset
    55
};
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
enum TPlaybackViewMode
hgs
parents:
diff changeset
    58
{
hgs
parents:
diff changeset
    59
    EFullScreenView,
hgs
parents:
diff changeset
    60
    EDetailsView,
hgs
parents:
diff changeset
    61
    EAudioOnlyView
hgs
parents:
diff changeset
    62
};
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
const int KMPXControlsTimeOut = 4000;
hgs
parents:
diff changeset
    65
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
// CLASS DECLARATION
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
class QMPXVideoPlaybackControlsController : public QObject
hgs
parents:
diff changeset
    70
{
hgs
parents:
diff changeset
    71
    Q_OBJECT
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
    public:
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
        /**
hgs
parents:
diff changeset
    76
        * constructor.
hgs
parents:
diff changeset
    77
        */
hgs
parents:
diff changeset
    78
        QMPXVideoPlaybackControlsController( QMPXVideoPlaybackViewFileDetails *details );
hgs
parents:
diff changeset
    79
hgs
parents:
diff changeset
    80
        /**
hgs
parents:
diff changeset
    81
        * Destructor.
hgs
parents:
diff changeset
    82
        */
hgs
parents:
diff changeset
    83
        virtual ~QMPXVideoPlaybackControlsController();
hgs
parents:
diff changeset
    84
hgs
parents:
diff changeset
    85
    public:
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
        /**
hgs
parents:
diff changeset
    88
        * Handle event from container
hgs
parents:
diff changeset
    89
        */
hgs
parents:
diff changeset
    90
        void handleEvent( TMPXVideoPlaybackControlCommandIds event, int value = 0 );
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
        /**
hgs
parents:
diff changeset
    93
        * Command handling function.
hgs
parents:
diff changeset
    94
        * Call HandleCommandL() of container
hgs
parents:
diff changeset
    95
        */
hgs
parents:
diff changeset
    96
        void handleCommand( TMPXVideoPlaybackViewCommandIds command, int value = 0 );
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
        /*
hgs
parents:
diff changeset
    99
        * Return ETrue if TV-out cable gets connected
hgs
parents:
diff changeset
   100
        */
hgs
parents:
diff changeset
   101
        inline bool isTvOutConnected();
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
        /*
hgs
parents:
diff changeset
   104
         * Return ETrue if TV-out cable is connected and content can be played
hgs
parents:
diff changeset
   105
         */
hgs
parents:
diff changeset
   106
        inline bool isTvOutPlaybackAllowed();
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
        /**
hgs
parents:
diff changeset
   109
        * Reset or cancel timers for the controls
hgs
parents:
diff changeset
   110
        */
hgs
parents:
diff changeset
   111
        void resetDisappearingTimers( TMPXTimerAction timerAction );
hgs
parents:
diff changeset
   112
hgs
parents:
diff changeset
   113
        /**
hgs
parents:
diff changeset
   114
        * Return state
hgs
parents:
diff changeset
   115
        */
hgs
parents:
diff changeset
   116
        inline TMPXPlaybackState state();
hgs
parents:
diff changeset
   117
hgs
parents:
diff changeset
   118
        /**
hgs
parents:
diff changeset
   119
        * Return file details
hgs
parents:
diff changeset
   120
        */
hgs
parents:
diff changeset
   121
        inline QMPXVideoPlaybackViewFileDetails* fileDetails();
hgs
parents:
diff changeset
   122
hgs
parents:
diff changeset
   123
        //
hgs
parents:
diff changeset
   124
        //  Add the file details to the controls controller when available
hgs
parents:
diff changeset
   125
        //
hgs
parents:
diff changeset
   126
        void addFileDetails( QMPXVideoPlaybackViewFileDetails* details );
hgs
parents:
diff changeset
   127
hgs
parents:
diff changeset
   128
        QMPXVideoPlaybackDocumentLoader* layoutLoader();
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
        inline bool isFlipView();
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
        void updateVideoRectDone();
hgs
parents:
diff changeset
   133
        
hgs
parents:
diff changeset
   134
        void changeViewMode( TPlaybackViewMode viewMode, bool transitionEffect = true );
hgs
parents:
diff changeset
   135
        
hgs
parents:
diff changeset
   136
        TPlaybackViewMode viewMode();
hgs
parents:
diff changeset
   137
hgs
parents:
diff changeset
   138
    public:
hgs
parents:
diff changeset
   139
        /**
hgs
parents:
diff changeset
   140
        * Initialize controller
hgs
parents:
diff changeset
   141
        */
hgs
parents:
diff changeset
   142
        void initializeController();
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
        /**
hgs
parents:
diff changeset
   145
        * Create controls
hgs
parents:
diff changeset
   146
        */
hgs
parents:
diff changeset
   147
        void createControls();
hgs
parents:
diff changeset
   148
hgs
parents:
diff changeset
   149
        /**
hgs
parents:
diff changeset
   150
        * Update controls
hgs
parents:
diff changeset
   151
        */
hgs
parents:
diff changeset
   152
        void handleStateChange( TMPXPlaybackState newState );
hgs
parents:
diff changeset
   153
hgs
parents:
diff changeset
   154
        /**
hgs
parents:
diff changeset
   155
        * Update Control's visibility
hgs
parents:
diff changeset
   156
        */
hgs
parents:
diff changeset
   157
        void updateControlsVisibility();
hgs
parents:
diff changeset
   158
hgs
parents:
diff changeset
   159
        /**
hgs
parents:
diff changeset
   160
        * Toggle visibility
hgs
parents:
diff changeset
   161
        */
hgs
parents:
diff changeset
   162
        void toggleVisibility();
hgs
parents:
diff changeset
   163
hgs
parents:
diff changeset
   164
        /**
hgs
parents:
diff changeset
   165
        * Create/delete controls based on updated control list
hgs
parents:
diff changeset
   166
        */
hgs
parents:
diff changeset
   167
        void controlsListUpdated();
hgs
parents:
diff changeset
   168
hgs
parents:
diff changeset
   169
        /**
hgs
parents:
diff changeset
   170
        * Show Controls and reset the timers
hgs
parents:
diff changeset
   171
        */
hgs
parents:
diff changeset
   172
        void showControls();
hgs
parents:
diff changeset
   173
hgs
parents:
diff changeset
   174
        /**
hgs
parents:
diff changeset
   175
        * Return ETrue if any control is visible
hgs
parents:
diff changeset
   176
        */
hgs
parents:
diff changeset
   177
        bool isVisible();
hgs
parents:
diff changeset
   178
hgs
parents:
diff changeset
   179
        /**
hgs
parents:
diff changeset
   180
        * Append a control based on control index
hgs
parents:
diff changeset
   181
        */
hgs
parents:
diff changeset
   182
        void appendControl( TMPXVideoPlaybackControls controlIndex );
hgs
parents:
diff changeset
   183
hgs
parents:
diff changeset
   184
        /**
hgs
parents:
diff changeset
   185
        * Set changed volume
hgs
parents:
diff changeset
   186
        */
hgs
parents:
diff changeset
   187
        void volumeChanged( int volume );
hgs
parents:
diff changeset
   188
hgs
parents:
diff changeset
   189
        /**
hgs
parents:
diff changeset
   190
        * Set changed duration
hgs
parents:
diff changeset
   191
        */
hgs
parents:
diff changeset
   192
        void durationChanged( int duration);
hgs
parents:
diff changeset
   193
hgs
parents:
diff changeset
   194
        /**
hgs
parents:
diff changeset
   195
        * Set changed position
hgs
parents:
diff changeset
   196
        */
hgs
parents:
diff changeset
   197
        void positionChanged( int position );
hgs
parents:
diff changeset
   198
hgs
parents:
diff changeset
   199
        /**
hgs
parents:
diff changeset
   200
        * Set changed position
hgs
parents:
diff changeset
   201
        */
hgs
parents:
diff changeset
   202
        void aspectRatioChanged( int aspectRatio );
hgs
parents:
diff changeset
   203
hgs
parents:
diff changeset
   204
        /*
hgs
parents:
diff changeset
   205
         *  Sets the download size on the progress bar
hgs
parents:
diff changeset
   206
         */
hgs
parents:
diff changeset
   207
        void setDownloadSize( int size );
hgs
parents:
diff changeset
   208
hgs
parents:
diff changeset
   209
        /*
hgs
parents:
diff changeset
   210
         *  Updates the download ratio on the progress bar
hgs
parents:
diff changeset
   211
         */
hgs
parents:
diff changeset
   212
        void updateDownloadPosition( int newSize );
hgs
parents:
diff changeset
   213
hgs
parents:
diff changeset
   214
        /**
hgs
parents:
diff changeset
   215
        * Set changed state on button bar
hgs
parents:
diff changeset
   216
        */
hgs
parents:
diff changeset
   217
        void updateStateOnButtonBar();
hgs
parents:
diff changeset
   218
hgs
parents:
diff changeset
   219
        /**
hgs
parents:
diff changeset
   220
        * Check whether this clip is real format or not
hgs
parents:
diff changeset
   221
        */
hgs
parents:
diff changeset
   222
        bool realFormat( QString filename );
hgs
parents:
diff changeset
   223
hgs
parents:
diff changeset
   224
        /**
hgs
parents:
diff changeset
   225
        * Check whether this clip is real format or not for streaming/live streaming
hgs
parents:
diff changeset
   226
        */
hgs
parents:
diff changeset
   227
        bool realFormatForStreaming( const TDesC& des );
hgs
parents:
diff changeset
   228
hgs
parents:
diff changeset
   229
        /**
hgs
parents:
diff changeset
   230
        * Check whether this clip is real format or not for local/progressive donwload
hgs
parents:
diff changeset
   231
        */
hgs
parents:
diff changeset
   232
        bool realFormatForLocal();
hgs
parents:
diff changeset
   233
        
hgs
parents:
diff changeset
   234
        /**
hgs
parents:
diff changeset
   235
        * Handle errors
hgs
parents:
diff changeset
   236
        */
hgs
parents:
diff changeset
   237
        void handleErrors(); 
hgs
parents:
diff changeset
   238
        
hgs
parents:
diff changeset
   239
        /**
hgs
parents:
diff changeset
   240
		* Return ETrue if control is visible
hgs
parents:
diff changeset
   241
		*/
hgs
parents:
diff changeset
   242
		bool isSoftKeyVisible( int value );
hgs
parents:
diff changeset
   243
hgs
parents:
diff changeset
   244
        /**
hgs
parents:
diff changeset
   245
        * Handle tvout connected/disconnected event
hgs
parents:
diff changeset
   246
        */
hgs
parents:
diff changeset
   247
    void handleTvOutEvent( bool connected, 
hgs
parents:
diff changeset
   248
		                        TMPXVideoPlaybackControlCommandIds event,
hgs
parents:
diff changeset
   249
		                        int value );
hgs
parents:
diff changeset
   250
hgs
parents:
diff changeset
   251
		HbAction* createAction( QActionGroup *actionsGroup,
hgs
parents:
diff changeset
   252
		                        int index,
hgs
parents:
diff changeset
   253
		                        const char *slot,
hgs
parents:
diff changeset
   254
		                        const QString& toolTip );
hgs
parents:
diff changeset
   255
hgs
parents:
diff changeset
   256
		void updateVideoRect(  bool transitionEffect = true ); 
hgs
parents:
diff changeset
   257
hgs
parents:
diff changeset
   258
		void showVolumeControls();
hgs
parents:
diff changeset
   259
hgs
parents:
diff changeset
   260
    private slots:
hgs
parents:
diff changeset
   261
        void hideAllControls();
hgs
parents:
diff changeset
   262
        void skipToNextVideoItem();
hgs
parents:
diff changeset
   263
        void skipToPreviousVideoItem();
hgs
parents:
diff changeset
   264
        void handleTappedOnScreen();
hgs
parents:
diff changeset
   265
hgs
parents:
diff changeset
   266
    public:
hgs
parents:
diff changeset
   267
        QMPXVideoPlaybackViewFileDetails          *mFileDetails;
hgs
parents:
diff changeset
   268
hgs
parents:
diff changeset
   269
        QList<QMPXVideoPlaybackFullScreenControl*> mControls;
hgs
parents:
diff changeset
   270
hgs
parents:
diff changeset
   271
        QMPXVideoPlaybackControlPolicy            *mControlsPolicy;
hgs
parents:
diff changeset
   272
        QMPXVideoPlaybackControlConfiguration     *mControlsConfig;
hgs
parents:
diff changeset
   273
hgs
parents:
diff changeset
   274
        QTimer                                    *mControlsTimer;
hgs
parents:
diff changeset
   275
hgs
parents:
diff changeset
   276
        QMPXVideoPlaybackDocumentLoader           *mLoader;
hgs
parents:
diff changeset
   277
        QMPXVideoPlaybackNonTouchVolumeBar        *mVolumeControl;
hgs
parents:
diff changeset
   278
hgs
parents:
diff changeset
   279
        bool                                       mFlipViewOpened;
hgs
parents:
diff changeset
   280
        bool                                       mViewTransitionIsGoingOn;
hgs
parents:
diff changeset
   281
        TMPXPlaybackState                          mState;
hgs
parents:
diff changeset
   282
        TPlaybackViewMode                          mViewMode;
hgs
parents:
diff changeset
   283
        
hgs
parents:
diff changeset
   284
};
hgs
parents:
diff changeset
   285
hgs
parents:
diff changeset
   286
// INLINE METHODS
hgs
parents:
diff changeset
   287
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   288
//   QMPXVideoPlaybackControlsController::state
hgs
parents:
diff changeset
   289
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   290
//
hgs
parents:
diff changeset
   291
inline
hgs
parents:
diff changeset
   292
TMPXPlaybackState QMPXVideoPlaybackControlsController::state()
hgs
parents:
diff changeset
   293
{
hgs
parents:
diff changeset
   294
    return mState;
hgs
parents:
diff changeset
   295
}
hgs
parents:
diff changeset
   296
hgs
parents:
diff changeset
   297
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   298
//   QMPXVideoPlaybackControlsController::fileDetails
hgs
parents:
diff changeset
   299
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   300
//
hgs
parents:
diff changeset
   301
inline
hgs
parents:
diff changeset
   302
QMPXVideoPlaybackViewFileDetails* QMPXVideoPlaybackControlsController::fileDetails()
hgs
parents:
diff changeset
   303
{
hgs
parents:
diff changeset
   304
    return mFileDetails;
hgs
parents:
diff changeset
   305
}
hgs
parents:
diff changeset
   306
hgs
parents:
diff changeset
   307
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   308
//   QMPXVideoPlaybackControlsController::isTvOutConnected
hgs
parents:
diff changeset
   309
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   310
//
hgs
parents:
diff changeset
   311
inline
hgs
parents:
diff changeset
   312
bool QMPXVideoPlaybackControlsController::isTvOutConnected()
hgs
parents:
diff changeset
   313
{
hgs
parents:
diff changeset
   314
    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isTvOutConnected(%d)"),
hgs
parents:
diff changeset
   315
            mFileDetails->mTvOutConnected);
hgs
parents:
diff changeset
   316
hgs
parents:
diff changeset
   317
    return mFileDetails->mTvOutConnected;
hgs
parents:
diff changeset
   318
}
hgs
parents:
diff changeset
   319
hgs
parents:
diff changeset
   320
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   321
//   QMPXVideoPlaybackControlsController::isTvOutPlaybackAllowed
hgs
parents:
diff changeset
   322
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   323
//
hgs
parents:
diff changeset
   324
inline
hgs
parents:
diff changeset
   325
bool QMPXVideoPlaybackControlsController::isTvOutPlaybackAllowed()
hgs
parents:
diff changeset
   326
{
hgs
parents:
diff changeset
   327
    bool playable = ( ! mFileDetails->mTvOutConnected || mFileDetails->mTvOutPlayAllowed );
hgs
parents:
diff changeset
   328
hgs
parents:
diff changeset
   329
    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isTvOutPlaybackAllowed() [%d]"),
hgs
parents:
diff changeset
   330
            playable);
hgs
parents:
diff changeset
   331
hgs
parents:
diff changeset
   332
    return playable;
hgs
parents:
diff changeset
   333
}
hgs
parents:
diff changeset
   334
hgs
parents:
diff changeset
   335
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   336
//   QMPXVideoPlaybackControlsController::isFlipView
hgs
parents:
diff changeset
   337
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   338
//
hgs
parents:
diff changeset
   339
inline
hgs
parents:
diff changeset
   340
bool QMPXVideoPlaybackControlsController::isFlipView()
hgs
parents:
diff changeset
   341
{
hgs
parents:
diff changeset
   342
    return mFlipViewOpened;
hgs
parents:
diff changeset
   343
}
hgs
parents:
diff changeset
   344
hgs
parents:
diff changeset
   345
hgs
parents:
diff changeset
   346
#endif /*MPXVIDEOPLAYBACKCONTROLSCONTROLLER_P_H_*/
hgs
parents:
diff changeset
   347
hgs
parents:
diff changeset
   348
// End of File