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