videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackcontrolscontroller.cpp
changeset 15 cf5481c2bc0b
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of MPXVideoPlaybackControlsController
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: da1mmcf#29 %
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <coecntrl.h>
       
    24 #include <bautils.h>
       
    25 #include <barsread.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 #include <QTimer>
       
    29 #include <QFileInfo>
       
    30 #include <thumbnailmanager_qt.h>
       
    31 
       
    32 #include <hblabel.h>
       
    33 #include <hbaction.h>
       
    34 #include <hbiconitem.h>
       
    35 #include <hbratingslider.h>
       
    36 #include <hbiconanimator.h>
       
    37 #include <hbtransparentwindow.h>
       
    38 #include <hbiconanimationmanager.h>
       
    39 
       
    40 #include "mpxvideoviewwrapper.h"
       
    41 #include "hbvideobaseplaybackview.h"
       
    42 #include "mpxvideoplaybackcontrolbar.h"
       
    43 #include "mpxvideoplaybackcontrolpolicy.h"
       
    44 #include "mpxvideoplaybackdocumentloader.h"
       
    45 #include "mpxvideoplaybackviewfiledetails.h"
       
    46 #include "mpxvideoplaybackstatuspanecontrol.h"
       
    47 #include "mpxvideoplaybackfiledetailswidget.h"
       
    48 #include "mpxvideoplaybacknontouchvolumebar.h"
       
    49 #include "mpxvideoplaybackfullscreencontrol.h"
       
    50 #include "mpxvideoplaybackcontrolscontroller.h"
       
    51 #include "mpxvideoplaybackcontrolconfiguration.h"
       
    52 #include "mpxvideoplaybackdetailsplaybackwindow.h"
       
    53 
       
    54 
       
    55 // ================= MEMBER FUNCTIONS ==============================================================
       
    56 
       
    57 // -------------------------------------------------------------------------------------------------
       
    58 // QMPXVideoPlaybackControlsController::QMPXVideoPlaybackControlsController()
       
    59 // -------------------------------------------------------------------------------------------------
       
    60 //
       
    61 QMPXVideoPlaybackControlsController::QMPXVideoPlaybackControlsController(
       
    62         HbVideoBasePlaybackView *view,
       
    63         CMPXVideoViewWrapper *viewWrapper,
       
    64         QMPXVideoPlaybackViewFileDetails *details )
       
    65     : mView( view )
       
    66     , mViewWrapper( viewWrapper )
       
    67     , mFileDetails( details )
       
    68     , mControlsPolicy( NULL )
       
    69     , mControlsConfig( NULL )
       
    70     , mControlsTimer( NULL )
       
    71     , mLoader( NULL )
       
    72     , mVolumeControl( NULL )
       
    73     , mThumbnailManager( NULL )
       
    74     , mViewTransitionIsGoingOn( false )
       
    75     , mThumbNailState( EThumbNailEmpty )
       
    76     , mState( EPbStateNotInitialised )
       
    77     , mViewMode( EFullScreenView )
       
    78 {
       
    79     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::QMPXVideoPlaybackControlsController()"));
       
    80 
       
    81     initializeController();
       
    82 }
       
    83 
       
    84 // -------------------------------------------------------------------------------------------------
       
    85 // QMPXVideoPlaybackControlsController::initializeController()
       
    86 // -------------------------------------------------------------------------------------------------
       
    87 //
       
    88 void QMPXVideoPlaybackControlsController::initializeController()
       
    89 {
       
    90     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::initializeController()"));
       
    91 
       
    92     setParent( mView );
       
    93 
       
    94     //
       
    95     // Create layout loader
       
    96     //
       
    97     bool ok = false;
       
    98     mLoader = new QMPXVideoPlaybackDocumentLoader( this );
       
    99     mLoader->load( KMPXPLAYBACKVIEW_XML, &ok );
       
   100 
       
   101     if ( ok )
       
   102     {
       
   103         QGraphicsWidget *widget = mLoader->findWidget( QString( "content" ) );
       
   104         mView->setWidget( widget );
       
   105 
       
   106         widget = mLoader->findWidget( QString( "volumeSlider" ) );
       
   107         mVolumeControl = qobject_cast<QMPXVideoPlaybackNonTouchVolumeBar*>( widget );
       
   108     }
       
   109     else
       
   110     {
       
   111         MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::initializeController()- can't find xml"));
       
   112 
       
   113         //
       
   114         // Can't find xml for layout. Delete mLoader
       
   115         //
       
   116         delete mLoader;
       
   117         mLoader = NULL;
       
   118     }
       
   119 
       
   120     mControlsPolicy = new QMPXVideoPlaybackControlPolicy();
       
   121     mControlsConfig = new QMPXVideoPlaybackControlConfiguration( this );
       
   122 
       
   123     connect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
       
   124     
       
   125     mControlsTimer = new QTimer( this );
       
   126     mControlsTimer->setInterval( KMPXControlsTimeOut );
       
   127     mControlsTimer->setSingleShot( false );
       
   128     connect( mControlsTimer, SIGNAL( timeout() ), this, SLOT( hideAllControls() ) );
       
   129 
       
   130     connect( mView, SIGNAL( tappedOnScreen() ), this, SLOT( handleTappedOnScreen() ) );
       
   131 }
       
   132 
       
   133 // -------------------------------------------------------------------------------------------------
       
   134 // QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController
       
   135 // -------------------------------------------------------------------------------------------------
       
   136 //
       
   137 QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController()
       
   138 {
       
   139     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController"));
       
   140 
       
   141     disconnect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
       
   142 
       
   143     disconnect( mView, SIGNAL( tappedOnScreen() ), this, SLOT( handleTappedOnScreen() ) );
       
   144     disconnect( mControlsTimer, SIGNAL( timeout() ), this, SLOT( hideAllControls() ) );
       
   145 
       
   146     mView->setWidget( NULL );
       
   147 
       
   148     mControls.clear();
       
   149 
       
   150     if ( mControlsTimer )
       
   151     {
       
   152         delete mControlsTimer;
       
   153         mControlsTimer = NULL;
       
   154     }
       
   155 
       
   156     if ( mControlsPolicy )
       
   157     {
       
   158         delete mControlsPolicy;
       
   159         mControlsPolicy = NULL;
       
   160     }
       
   161 
       
   162     if ( mControlsConfig )
       
   163     {
       
   164         delete mControlsConfig;
       
   165         mControlsConfig = NULL;
       
   166     }
       
   167 
       
   168     if ( mLoader )
       
   169     {
       
   170         delete mLoader;
       
   171         mLoader = NULL;
       
   172     }
       
   173 
       
   174     if ( mThumbnailManager )
       
   175     {
       
   176         delete mThumbnailManager;
       
   177         mThumbnailManager = 0;                    
       
   178     }
       
   179 }
       
   180 
       
   181 // -------------------------------------------------------------------------------------------------
       
   182 // QMPXVideoPlaybackControlsController::addFileDetails()
       
   183 // -------------------------------------------------------------------------------------------------
       
   184 //
       
   185 void QMPXVideoPlaybackControlsController::addFileDetails(
       
   186     QMPXVideoPlaybackViewFileDetails* details )
       
   187 {
       
   188     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::addFileDetails"));
       
   189 
       
   190     //
       
   191     // If it is not local, hide the star rating
       
   192     //
       
   193     if ( details->mPlaybackMode != EMPXVideoLocal )
       
   194     {
       
   195         QString sectionName = "nonLocalPlayback";
       
   196 
       
   197         bool ok = false;
       
   198         mLoader->load( KMPXPLAYBACKVIEW_XML, sectionName, &ok );
       
   199     }
       
   200 
       
   201     mFileDetails = details;
       
   202 
       
   203     mFileDetails->mRNFormat = realFormat( mFileDetails->mClipName );
       
   204 
       
   205     mControlsConfig->updateControlsWithFileDetails();
       
   206 
       
   207     //
       
   208     // for audio-only clips and tv-out, default view is flip view
       
   209     //
       
   210     if ( ! details->mVideoEnabled )
       
   211     {
       
   212         changeViewMode( EAudioOnlyView, false );
       
   213     }
       
   214 
       
   215     if ( details->mTvOutConnected )
       
   216     {
       
   217         handleEvent( EMPXControlCmdTvOutConnected, details->mTvOutPlayAllowed );
       
   218     }
       
   219 
       
   220     //
       
   221     // Dimmed the volume control if it is video only
       
   222     //
       
   223     if ( ! mFileDetails->mAudioEnabled )
       
   224     {
       
   225         mVolumeControl->setValue( 0 );
       
   226         mVolumeControl->setEnabled( false );
       
   227     }
       
   228 
       
   229     //
       
   230     // If title is not available, show clip name
       
   231     //
       
   232     QString title = mFileDetails->mTitle;
       
   233 
       
   234     if ( title.count() == 0 )
       
   235     {
       
   236         QFileInfo fileInfo( mFileDetails->mClipName );
       
   237         title = fileInfo.baseName ();
       
   238     }
       
   239 
       
   240     QGraphicsWidget *widget = mLoader->findWidget( QString( "title" ) );
       
   241     HbLabel *titleLabel = qobject_cast<HbLabel*>( widget );
       
   242     titleLabel->setPlainText( title );
       
   243 }
       
   244 
       
   245 // -------------------------------------------------------------------------------------------------
       
   246 // QMPXVideoPlaybackControlsController::handleEvent
       
   247 // -------------------------------------------------------------------------------------------------
       
   248 //
       
   249 void QMPXVideoPlaybackControlsController::handleEvent(
       
   250     TMPXVideoPlaybackControlCommandIds event, int value )
       
   251 {
       
   252     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::handleEvent(%d)"), event);
       
   253 
       
   254     switch ( event )
       
   255     {
       
   256         case EMPXControlCmdSetPosition:
       
   257         {
       
   258             MPX_DEBUG(_L("    [EMPXControlCmdSetPosition [%d]]"), value );
       
   259 
       
   260             positionChanged( (qreal)value / (qreal)KPbMilliMultiplier);
       
   261             break;
       
   262         }
       
   263         case EMPXControlCmdSetDuration:
       
   264         {
       
   265             MPX_DEBUG(_L("    [EMPXControlCmdSetDuration [%d]]"), value );
       
   266 
       
   267             durationChanged( (qreal)value / (qreal)KPbMilliMultiplier );
       
   268             break;
       
   269         }
       
   270         case EMPXControlCmdStateChanged:
       
   271         {
       
   272             MPX_DEBUG(_L("    [EMPXControlCmdStateChanged]"));
       
   273 
       
   274             handleStateChange( (TMPXPlaybackState)value );
       
   275             break;
       
   276         }
       
   277         case EMPXControlCmdSetVolume:
       
   278         {
       
   279             MPX_DEBUG(_L("    [EMPXControlCmdSetVolume [%d]]"), value );
       
   280 
       
   281             volumeChanged( value );
       
   282             break;
       
   283         }
       
   284         case EMPXControlCmdSetAspectRatio:
       
   285         {
       
   286             MPX_DEBUG(_L("    [EMPXControlCmdSetAspectRatio %d]"), value );
       
   287 
       
   288             aspectRatioChanged( value );
       
   289 
       
   290             break;
       
   291         }
       
   292         case EMPXControlCmdSetDownloadSize:
       
   293         {
       
   294             MPX_DEBUG(_L("    [EMPXControlCmdSetDownloadSize [%d]]"), value );
       
   295             setDownloadSize( value );
       
   296             break;
       
   297         }
       
   298         case EMPXControlCmdDownloadUpdated:
       
   299         {
       
   300             MPX_DEBUG(_L("    [EMPXControlCmdDownloadUpdated [%d]]"), value );
       
   301             updateDownloadPosition( value );
       
   302             break;
       
   303         }
       
   304         case EMPXControlCmdDownloadComplete:
       
   305         {
       
   306             MPX_DEBUG(_L("    [EMPXControlCmdDownloadComplete [%d]]"), value);
       
   307             updateDownloadPosition( value );
       
   308             break;
       
   309         }
       
   310         case EMPXControlCmdSetDownloadPaused:
       
   311         case EMPXControlCmdClearDownloadPaused:
       
   312         {
       
   313             mControlsConfig->updateControlList( event );
       
   314             break;
       
   315         }
       
   316         case EMPXControlCmdTvOutConnected:
       
   317         {
       
   318             MPX_DEBUG(_L("    [EMPXControlCmdTvOutConnected]"));
       
   319 
       
   320             handleTvOutEvent( true, event, value );
       
   321             break;
       
   322         }
       
   323         case EMPXControlCmdTvOutDisconnected:
       
   324         {
       
   325             MPX_DEBUG(_L("    [EMPXControlCmdTvOutDisConnected]"));
       
   326 
       
   327             handleTvOutEvent( false, event, value );
       
   328             break;
       
   329         }
       
   330         case EMPXControlCmdHandleErrors:
       
   331         {
       
   332             MPX_DEBUG(_L("    [EMPXControlCmdHandleErrors]"));
       
   333 
       
   334             handleErrors();
       
   335 
       
   336             break;
       
   337         }
       
   338         case EMPXControlCmdShowVolumeControls:
       
   339         {
       
   340             MPX_DEBUG(_L("    [EMPXControlCmdShowVolumeControls]"));
       
   341 
       
   342             showVolumeControls();
       
   343             break;
       
   344         }
       
   345     }
       
   346 }
       
   347 
       
   348 // -------------------------------------------------------------------------------------------------
       
   349 // QMPXVideoPlaybackControlsController::handleStateChange
       
   350 // -------------------------------------------------------------------------------------------------
       
   351 //
       
   352 void QMPXVideoPlaybackControlsController::handleStateChange( TMPXPlaybackState newState )
       
   353 {
       
   354     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleStateChange()"),
       
   355                    _L("new state = %d"), newState );
       
   356 
       
   357     //
       
   358     // Somehow EPbStatePlaying, EPbStatePaused gets called twice continously
       
   359     //
       
   360     if ( newState != mState )
       
   361     {
       
   362         mState = newState;
       
   363 
       
   364         switch ( newState )
       
   365         {
       
   366             case EPbStateInitialised:
       
   367             {
       
   368                 //
       
   369                 //  remove branding control when the state is transitioned to Initialized
       
   370                 //
       
   371                 if ( mFileDetails->mPlaybackMode == EMPXVideoStreaming ||
       
   372                      mFileDetails->mPlaybackMode == EMPXVideoLiveStreaming )
       
   373                 {
       
   374                     mControlsConfig->updateControlList( EMPXControlCmdPluginInitialized ); 
       
   375                 }
       
   376                 
       
   377                 break;                
       
   378             }
       
   379             case EPbStatePlaying:
       
   380             case EPbStateInitialising:
       
   381             case EPbStateBuffering:
       
   382             case EPbStatePaused:
       
   383             case EPbStateNotInitialised:
       
   384             {
       
   385                 updateState();
       
   386 
       
   387                 //
       
   388                 //  Show all the controls
       
   389                 //
       
   390                 showControls();
       
   391 
       
   392                 break;
       
   393             }
       
   394         }
       
   395     }
       
   396 }
       
   397 
       
   398 // -------------------------------------------------------------------------------------------------
       
   399 // QMPXVideoPlaybackControlsController::controlsListUpdated()
       
   400 // -------------------------------------------------------------------------------------------------
       
   401 //
       
   402 void QMPXVideoPlaybackControlsController::controlsListUpdated()
       
   403 {
       
   404     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::controlsListUpdated()"));
       
   405 
       
   406     hideAllControls();
       
   407 
       
   408     QList<TMPXVideoPlaybackControls>& updatedList = mControlsConfig->controlList();
       
   409 
       
   410     QList<TMPXVideoPlaybackControls> myList = updatedList;
       
   411 
       
   412     int controlCount = mControls.count();
       
   413 
       
   414     int i = 0 ;
       
   415     int index = KErrNotFound;
       
   416 
       
   417 
       
   418     for ( int iCnt = 0 ; iCnt < controlCount ; iCnt++ )
       
   419     {
       
   420         index = myList.indexOf( mControls[i]->controlIndex() );
       
   421 
       
   422         if ( index == KErrNotFound )
       
   423         {
       
   424             //
       
   425             //  Delete control since it doesn't exist in new list
       
   426             //
       
   427             mControls.removeAt( i );
       
   428         }
       
   429         else
       
   430         {
       
   431             //
       
   432             //  Control exists in new list.
       
   433             //  Update the policy property based on file details and view mode to the controls
       
   434             //
       
   435             TUint properties = 0;
       
   436             mControlsPolicy->setControlProperties( 
       
   437                     mControls[i]->controlIndex(), properties, mFileDetails, mViewMode );
       
   438             mControls[i]->updateControlProperties( properties );
       
   439 
       
   440             //
       
   441             //  Control exists in new list.
       
   442             //
       
   443             myList.removeAt( index );
       
   444             i++;            
       
   445         }
       
   446     }
       
   447 
       
   448     //
       
   449     //  The updated list will contain added controls only
       
   450     //
       
   451     for ( int j = 0 ; j < myList.count() ; j++ )
       
   452     {
       
   453         appendControl( myList[j] );
       
   454     }
       
   455 
       
   456     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   457     {
       
   458         mControls[i]->updateControlsWithFileDetails( mFileDetails );
       
   459     }
       
   460 
       
   461     showControls();
       
   462 }
       
   463 
       
   464 // -------------------------------------------------------------------------------------------------
       
   465 // QMPXVideoPlaybackControlsController::appendControl()
       
   466 // -------------------------------------------------------------------------------------------------
       
   467 //
       
   468 void QMPXVideoPlaybackControlsController::appendControl( TMPXVideoPlaybackControls controlIndex )
       
   469 {
       
   470     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::appendControl()"),
       
   471                    _L("control index = %d"), controlIndex );
       
   472 
       
   473     TUint properties = 0;
       
   474 
       
   475     mControlsPolicy->setControlProperties( controlIndex, properties, mFileDetails, mViewMode );
       
   476     QMPXVideoPlaybackFullScreenControl* control;
       
   477 
       
   478     switch ( controlIndex )
       
   479     {
       
   480         case EMPXBufferingAnimation:
       
   481         {
       
   482             //
       
   483             // Buffering animation icon
       
   484             //
       
   485             HbIconAnimationManager* manager = HbIconAnimationManager::global();
       
   486             manager->addDefinitionFile(":/hbvideoplaybackview/animation.axml");
       
   487 			
       
   488             QGraphicsWidget *widget = mLoader->findWidget( QString( "bufferingIcon" ) );
       
   489             HbLabel *bufferingAnim = qobject_cast<HbLabel*>( widget );
       
   490 
       
   491             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   492                                                               controlIndex,
       
   493                                                               bufferingAnim,
       
   494                                                               properties );
       
   495             mControls.append( control );
       
   496 
       
   497             break;
       
   498         }
       
   499         case EMPXStatusPane:
       
   500         {
       
   501             //
       
   502             // Status key (signal + title + back key)
       
   503             //
       
   504             control = new QMPXVideoPlaybackStatusPaneControl( this,
       
   505                                                               controlIndex, 
       
   506                                                               NULL,
       
   507                                                               properties );
       
   508             mControls.append( control );
       
   509 
       
   510             break;
       
   511         }
       
   512         case EMPXControlBar:
       
   513         {
       
   514             //
       
   515             // Button bar
       
   516             //
       
   517             QGraphicsWidget *widget = mLoader->findWidget( QString( "controlBarLayout" ) );
       
   518             QMPXVideoPlaybackControlBar *controlBar = 
       
   519                 qobject_cast<QMPXVideoPlaybackControlBar*>( widget );
       
   520             controlBar->initialize();
       
   521 
       
   522             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   523                                                               controlIndex,
       
   524                                                               controlBar,
       
   525                                                               properties );
       
   526             mControls.append( control );
       
   527 
       
   528             break;
       
   529         }
       
   530         case EMPXFileDetailsWidget:
       
   531         {
       
   532             QGraphicsWidget *widget = mLoader->findWidget( QString( "fileDetailsLayout" ) );
       
   533             QMPXVideoPlaybackFileDetailsWidget *fileDetails = 
       
   534                 qobject_cast<QMPXVideoPlaybackFileDetailsWidget*>( widget );
       
   535             fileDetails->initialize();
       
   536 
       
   537             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   538                                                               controlIndex,
       
   539                                                               fileDetails,
       
   540                                                               properties );
       
   541 
       
   542             mControls.append( control );
       
   543             break;
       
   544         }
       
   545         case EMPXIndicatorBitmap:
       
   546         {
       
   547             QGraphicsWidget *widget = mLoader->findWidget( QString( "bitmapLayout" ) );
       
   548             HbWidget *bitmapWidget = qobject_cast<HbWidget*>( widget );
       
   549 
       
   550             setDefaultBitmap();
       
   551             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   552                                                               controlIndex,
       
   553                                                               bitmapWidget,
       
   554                                                               properties );
       
   555             mControls.append( control );
       
   556 
       
   557             break;
       
   558         }
       
   559         case EMPXDetailsViewPlaybackWindow:
       
   560         {
       
   561             QGraphicsWidget *widget = mLoader->findWidget( QString( "detailsPlaybackWindow" ) );
       
   562             QMPXVideoPlaybackDetailsPlaybackWindow *detailsPlaybackWindow = 
       
   563                     qobject_cast<QMPXVideoPlaybackDetailsPlaybackWindow*>( widget );
       
   564             detailsPlaybackWindow->initialize();
       
   565 
       
   566             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   567                                                               controlIndex,
       
   568                                                               detailsPlaybackWindow,
       
   569                                                               properties );
       
   570             mControls.append( control );
       
   571 
       
   572             break;
       
   573         }
       
   574     }
       
   575 }
       
   576 
       
   577 // -------------------------------------------------------------------------------------------------
       
   578 // QMPXVideoPlaybackControlsController::handleTappedOnScreen()
       
   579 // -------------------------------------------------------------------------------------------------
       
   580 //
       
   581 void QMPXVideoPlaybackControlsController::handleTappedOnScreen()
       
   582 
       
   583 {
       
   584     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleTappedOnScreen()"));
       
   585 
       
   586     //
       
   587     //  Toggle visibility only if the followings are true 
       
   588     //  - TV-Out is not connected
       
   589     //  - Video is available
       
   590     //  - We are in playing or paused state
       
   591     //
       
   592     if ( ! isTvOutConnected() &&
       
   593          mFileDetails->mVideoEnabled &&
       
   594          ( mState == EPbStatePlaying || mState == EPbStatePaused ) )
       
   595     {
       
   596         if ( mViewMode == EFullScreenView )
       
   597         {
       
   598             if ( isVisible() )
       
   599             {
       
   600                 //
       
   601                 // If the volume control is visible, hide it
       
   602                 //
       
   603                 if ( mVolumeControl->isVisible() )
       
   604                 {
       
   605                     mVolumeControl->setVisible( false );
       
   606                 }
       
   607 
       
   608                 hideAllControls();
       
   609             }
       
   610             else
       
   611             {
       
   612                 showControls();
       
   613             }            
       
   614         }
       
   615     }
       
   616 }
       
   617 
       
   618 // -------------------------------------------------------------------------------------------------
       
   619 // QMPXVideoPlaybackControlsController::resetDisappearingTimers()
       
   620 // -------------------------------------------------------------------------------------------------
       
   621 //
       
   622 void QMPXVideoPlaybackControlsController::resetDisappearingTimers( TMPXTimerAction timerAction )
       
   623 {
       
   624     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::resetDisappearingTimers()"));
       
   625 
       
   626     if ( mControlsTimer->isActive() )
       
   627     {
       
   628         mControlsTimer->stop();
       
   629     }
       
   630 
       
   631     //
       
   632     //  Do not start the time for DetailsView and AudioOnlyView
       
   633     //
       
   634     if ( timerAction == EMPXTimerReset &&
       
   635          mState == EPbStatePlaying &&
       
   636          mViewMode == EFullScreenView )
       
   637     {
       
   638         MPX_DEBUG(_L("    Starting Controls Timer"));
       
   639 
       
   640         mControlsTimer->start();
       
   641     }
       
   642 }
       
   643 
       
   644 // -------------------------------------------------------------------------------------------------
       
   645 //   QMPXVideoPlaybackControlsController::hideAllControls()
       
   646 // -------------------------------------------------------------------------------------------------
       
   647 //
       
   648 void QMPXVideoPlaybackControlsController::hideAllControls()
       
   649 {
       
   650     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::hideControls()"));
       
   651 
       
   652     resetDisappearingTimers( EMPXTimerCancel );
       
   653 
       
   654     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   655     {
       
   656         mControls[i]->setVisible( false );
       
   657     }
       
   658 }
       
   659 
       
   660 // -------------------------------------------------------------------------------------------------
       
   661 //   QMPXVideoPlaybackControlsController::showControls()
       
   662 // -------------------------------------------------------------------------------------------------
       
   663 //
       
   664 void QMPXVideoPlaybackControlsController::showControls()
       
   665 {
       
   666     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::showControls()"));
       
   667 
       
   668     resetDisappearingTimers( EMPXTimerReset );
       
   669 
       
   670     if ( ! mViewTransitionIsGoingOn )
       
   671     {
       
   672         for ( int i = 0 ; i < mControls.count() ; i++ )
       
   673         {
       
   674             mControls[i]->setVisibility( mState );
       
   675         }
       
   676     }        
       
   677 }
       
   678 
       
   679 // -------------------------------------------------------------------------------------------------
       
   680 //   QMPXVideoPlaybackControlsController::isVisible()
       
   681 // -------------------------------------------------------------------------------------------------
       
   682 //
       
   683 bool QMPXVideoPlaybackControlsController::isVisible()
       
   684 {
       
   685     bool visible = EFalse;
       
   686 
       
   687     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   688     {
       
   689         if ( mControls[i]->controlIndex() == EMPXControlBar )
       
   690         {
       
   691             if ( mControls[i]->isVisible() )
       
   692             {
       
   693                 visible = ETrue;
       
   694             }
       
   695 
       
   696             break;
       
   697         }
       
   698     }
       
   699 
       
   700     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isVisible() [%d]"), visible);
       
   701 
       
   702     return visible;
       
   703 }
       
   704 
       
   705 // -------------------------------------------------------------------------------------------------
       
   706 //   QMPXVideoPlaybackControlsController::handleCommand()
       
   707 // -------------------------------------------------------------------------------------------------
       
   708 //
       
   709 void QMPXVideoPlaybackControlsController::handleCommand( 
       
   710         TMPXVideoPlaybackViewCommandIds command, int value )
       
   711 {
       
   712     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::handleCommand(%d)"), command);
       
   713 
       
   714     switch( command )
       
   715     {
       
   716         case EMPXPbvCmdSetPosition:
       
   717         {
       
   718             TRAP_IGNORE( mViewWrapper->SetPropertyL( EPbPropertyPosition, 
       
   719                                                      value * KPbMilliMultiplier ) );
       
   720             break;
       
   721         }
       
   722         case EMPXPbvCmdSetVolume:
       
   723         {
       
   724             TRAP_IGNORE( mViewWrapper->SetPropertyL( EPbPropertyVolume, value ) );
       
   725             break;            
       
   726         }
       
   727         default:
       
   728         {
       
   729             TRAP_IGNORE( mViewWrapper->HandleCommandL( command ) );
       
   730             break;
       
   731         }
       
   732     }
       
   733 }
       
   734 
       
   735 // -------------------------------------------------------------------------------------------------
       
   736 //   QMPXVideoPlaybackControlsController::volumeChanged()
       
   737 // -------------------------------------------------------------------------------------------------
       
   738 //
       
   739 void QMPXVideoPlaybackControlsController::volumeChanged( int volume )
       
   740 {
       
   741     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::volumeChanged() [%d]"), volume);
       
   742 
       
   743     if ( mVolumeControl )
       
   744     {
       
   745         mVolumeControl->setValue( volume );
       
   746     }
       
   747 }
       
   748 
       
   749 // -------------------------------------------------------------------------------------------------
       
   750 //   QMPXVideoPlaybackControlsController::showVolumeControls()
       
   751 // -------------------------------------------------------------------------------------------------
       
   752 //
       
   753 void QMPXVideoPlaybackControlsController::showVolumeControls()
       
   754 {
       
   755     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::showVolumeControls()"));
       
   756 
       
   757     if ( mVolumeControl )
       
   758     {
       
   759         mVolumeControl->setVisible( true );
       
   760     }
       
   761 }
       
   762 
       
   763 // -------------------------------------------------------------------------------------------------
       
   764 //   QMPXVideoPlaybackControlsController::durationChanged()
       
   765 // -------------------------------------------------------------------------------------------------
       
   766 //
       
   767 void QMPXVideoPlaybackControlsController::durationChanged( int duration )
       
   768 {
       
   769     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::durationChanged() [%d]"), duration);
       
   770 
       
   771     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   772     {
       
   773         if ( mControls[i]->durationChanged( duration ) )
       
   774         {
       
   775             break;
       
   776         }
       
   777     }
       
   778 }
       
   779 
       
   780 // -------------------------------------------------------------------------------------------------
       
   781 //   QMPXVideoPlaybackControlsController::positionChanged()
       
   782 // -------------------------------------------------------------------------------------------------
       
   783 //
       
   784 void QMPXVideoPlaybackControlsController::positionChanged( int position )
       
   785 {
       
   786     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::positionChanged() [%d]"), position);
       
   787 
       
   788     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   789     {
       
   790         if ( mControls[i]->positionChanged( position ) )
       
   791         {
       
   792             break;
       
   793         }
       
   794     }
       
   795 }
       
   796 
       
   797 // -------------------------------------------------------------------------------------------------
       
   798 //   QMPXVideoPlaybackControlsController::aspectRatioChanged()
       
   799 // -------------------------------------------------------------------------------------------------
       
   800 //
       
   801 void QMPXVideoPlaybackControlsController::aspectRatioChanged( int aspectRatio )
       
   802 {
       
   803     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::aspectRatioChanged() [%d]"), aspectRatio);
       
   804 
       
   805     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   806     {
       
   807         if ( mControls[i]->aspectRatioChanged( aspectRatio ) )
       
   808         {
       
   809             break;
       
   810         }
       
   811     }
       
   812 }
       
   813 
       
   814 // -------------------------------------------------------------------------------------------------
       
   815 //   QMPXVideoPlaybackControlsController::updateState()
       
   816 // -------------------------------------------------------------------------------------------------
       
   817 //
       
   818 void QMPXVideoPlaybackControlsController::updateState()
       
   819 {
       
   820     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateState() [%d]"), mState);
       
   821 
       
   822     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   823     {
       
   824         mControls[i]->updateState( mState );
       
   825     }
       
   826 }
       
   827 
       
   828 // -------------------------------------------------------------------------------------------------
       
   829 // QMPXVideoPlaybackControlsController::realFormat()
       
   830 // -------------------------------------------------------------------------------------------------
       
   831 //
       
   832 bool QMPXVideoPlaybackControlsController::realFormat( QString filename )
       
   833 {
       
   834     bool realFormat = EFalse;
       
   835 
       
   836     if ( !filename.isNull() && !filename.isEmpty() )
       
   837     {
       
   838         if ( mFileDetails->mPlaybackMode == EMPXVideoStreaming ||
       
   839              mFileDetails->mPlaybackMode == EMPXVideoLiveStreaming )
       
   840         {
       
   841             TBufC<255> file(filename.utf16());
       
   842             realFormat = realFormatForStreaming( file );
       
   843         }
       
   844         else
       
   845         {
       
   846             realFormat = realFormatForLocal();
       
   847         }
       
   848     }
       
   849 
       
   850     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::realFormat() [%d]"), realFormat);
       
   851 
       
   852     return realFormat;
       
   853 }
       
   854 
       
   855 // -------------------------------------------------------------------------------------------------
       
   856 // QMPXVideoPlaybackControlsController::realFormatForStreaming()
       
   857 // -------------------------------------------------------------------------------------------------
       
   858 //
       
   859 bool QMPXVideoPlaybackControlsController::realFormatForStreaming( const TDesC& des )
       
   860 {
       
   861     bool realFormat = EFalse;
       
   862     TParse filePath;
       
   863 
       
   864     _LIT(KMPXRMEXT, ".R" );
       
   865 
       
   866     int err = filePath.Set( des, NULL, NULL );
       
   867 
       
   868     //
       
   869     // It is valid to have a "\" character in a url, but parsing fails,
       
   870     // switch these characters to "/" for the local string and try parsing again.
       
   871     //
       
   872     if ( err == KErrBadName )
       
   873     {
       
   874         int backsashPos = des.LocateF('\\');
       
   875 
       
   876         if( backsashPos != KErrNotFound )
       
   877         {
       
   878             HBufC* fileName = NULL;
       
   879 
       
   880             TRAP( err,  fileName = des.AllocL() );
       
   881 
       
   882             if ( err == KErrNone )
       
   883             {
       
   884                 int count( fileName->Des().Length() );
       
   885 
       
   886                 for ( int j = backsashPos ; j < count; ++j )
       
   887                 {
       
   888                     if ( fileName->Des()[j]== '\\' )
       
   889                     {
       
   890                         fileName->Des()[j]='/';
       
   891                     }
       
   892                 }
       
   893                 err = filePath.Set( fileName->Des(), NULL, NULL );                
       
   894             }
       
   895 
       
   896             if ( fileName )
       
   897             {
       
   898                 delete fileName;
       
   899                 fileName = NULL;
       
   900             }
       
   901         }
       
   902     }
       
   903 
       
   904     if ( err == KErrNone )
       
   905     {
       
   906         //
       
   907         // The requirement to support arguments with the extension in streaming links
       
   908         // for-ex: /video.3gp?start=10&end=40 will have to supported
       
   909         // as well. So just by doing p.Ext() would retrieve all the string
       
   910         // after "." so by doing a Left(2) would retrieve only
       
   911         // .3g or .rm and so on. This would help better
       
   912         // interpret the extension and decide the branding accordingly
       
   913         //
       
   914         filePath.Set( filePath.NameAndExt(), NULL, NULL );
       
   915         TPtrC extension = filePath.Ext().Left( 2 );
       
   916 
       
   917         TBuf<2> buf;
       
   918         buf.Format( extension );
       
   919         buf.UpperCase();
       
   920 
       
   921         // RealMedia Branding
       
   922         if ( ! buf.Compare( KMPXRMEXT ) )
       
   923         {
       
   924             realFormat = ETrue;
       
   925         }
       
   926     }
       
   927 
       
   928     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::realFormatForStreaming()[%d]"), realFormat);
       
   929 
       
   930     return realFormat;
       
   931 }
       
   932 
       
   933 // -------------------------------------------------------------------------------------------------
       
   934 // QMPXVideoPlaybackControlsController::realFormatForLocal()
       
   935 // -------------------------------------------------------------------------------------------------
       
   936 //
       
   937 bool QMPXVideoPlaybackControlsController::realFormatForLocal()
       
   938 {
       
   939     bool realFormat = false;
       
   940     
       
   941     QString real( "real" );
       
   942     QString rn( "rn" );
       
   943     
       
   944     if ( mFileDetails->mMimeType.contains( real, Qt::CaseInsensitive ) ||
       
   945          mFileDetails->mMimeType.contains( rn, Qt::CaseInsensitive ) )
       
   946     {
       
   947         realFormat = true;
       
   948     }
       
   949         
       
   950     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::realFormatForLocal() [%d]"), realFormat);
       
   951 
       
   952     return realFormat;
       
   953 }
       
   954 
       
   955 // -------------------------------------------------------------------------------------------------
       
   956 //   QMPXVideoPlaybackControlsController::setDownloadSize()
       
   957 // -------------------------------------------------------------------------------------------------
       
   958 //
       
   959 void QMPXVideoPlaybackControlsController::setDownloadSize( int size )
       
   960 {
       
   961     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::setDownloadSize() [%d]"), size);
       
   962 
       
   963     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   964     {
       
   965         if ( mControls[i]->setDownloadSize( size ) )
       
   966         {
       
   967             break;
       
   968         }
       
   969     }
       
   970 }
       
   971 
       
   972 // -------------------------------------------------------------------------------------------------
       
   973 //   QMPXVideoPlaybackControlsController::updateDownloadPosition()
       
   974 // -------------------------------------------------------------------------------------------------
       
   975 //
       
   976 void QMPXVideoPlaybackControlsController::updateDownloadPosition( int size )
       
   977 {
       
   978     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateDownloadPosition() [%d]"), size);
       
   979 
       
   980     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   981     {
       
   982         if ( mControls[i]->updateDownloadPosition( size ) )
       
   983         {
       
   984             break;
       
   985         }
       
   986     }
       
   987 }
       
   988 
       
   989 // -------------------------------------------------------------------------------------------------
       
   990 // QMPXVideoPlaybackControlsController::handleErrors
       
   991 // -------------------------------------------------------------------------------------------------
       
   992 //
       
   993 void QMPXVideoPlaybackControlsController::handleErrors()
       
   994 {
       
   995     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleErrors()"),
       
   996                    _L("mState = %d"), mState );
       
   997 }
       
   998 
       
   999 // -------------------------------------------------------------------------------------------------
       
  1000 //   QMPXVideoPlaybackControlsController::isSoftKeyVisible()
       
  1001 // -------------------------------------------------------------------------------------------------
       
  1002 //
       
  1003 bool QMPXVideoPlaybackControlsController::isSoftKeyVisible( int /*value*/ )
       
  1004 {
       
  1005     bool visible = EFalse;
       
  1006 
       
  1007     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1008     {
       
  1009         if ( mControls[i]->controlIndex() == EMPXStatusPane )
       
  1010         {
       
  1011             if ( mControls[i]->isVisible() )
       
  1012             {
       
  1013                 visible = ETrue;
       
  1014             }
       
  1015 
       
  1016             break;
       
  1017         }
       
  1018     }
       
  1019 
       
  1020     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isSoftKeyVisible() [%d]"), visible);
       
  1021 
       
  1022     return visible;
       
  1023 }
       
  1024 
       
  1025 // -------------------------------------------------------------------------------------------------
       
  1026 //   QMPXVideoPlaybackControlsController::handleTvOutEvent
       
  1027 // -------------------------------------------------------------------------------------------------
       
  1028 //
       
  1029 void QMPXVideoPlaybackControlsController::handleTvOutEvent(
       
  1030         bool connected, TMPXVideoPlaybackControlCommandIds event, int value )
       
  1031 {
       
  1032     Q_UNUSED( event );
       
  1033 
       
  1034     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::handleTvOutEvent()"));
       
  1035 
       
  1036     mFileDetails->mTvOutConnected = connected;
       
  1037 
       
  1038     setDefaultBitmap();
       
  1039 
       
  1040     if ( mFileDetails->mTvOutConnected )
       
  1041     {
       
  1042         generateThumbNail();
       
  1043         mFileDetails->mTvOutPlayAllowed = value;
       
  1044     }
       
  1045     else
       
  1046     {
       
  1047         mFileDetails->mTvOutPlayAllowed = ETrue;
       
  1048     }
       
  1049 
       
  1050     //
       
  1051     // Change the view. 
       
  1052     // If Tv-out is connected, go to AudioOnlyView.
       
  1053     // If not, go back to default view.
       
  1054     //
       
  1055     TPlaybackViewMode viewMode = EFullScreenView;
       
  1056 
       
  1057     if ( mFileDetails->mTvOutConnected || ! mFileDetails->mVideoEnabled )
       
  1058     {
       
  1059         viewMode = EAudioOnlyView;
       
  1060     }
       
  1061 
       
  1062     changeViewMode( viewMode, false );
       
  1063 }
       
  1064 
       
  1065 // -------------------------------------------------------------------------------------------------
       
  1066 //   QMPXVideoPlaybackControlsController::changeViewMode
       
  1067 // -------------------------------------------------------------------------------------------------
       
  1068 //
       
  1069 void QMPXVideoPlaybackControlsController::changeViewMode( 
       
  1070         TPlaybackViewMode viewMode, bool transitionEffect )
       
  1071 {
       
  1072     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::changeViewMode()"));
       
  1073 
       
  1074     if ( viewMode != mViewMode )
       
  1075     {
       
  1076         switch ( viewMode )
       
  1077         {
       
  1078             case EFullScreenView:
       
  1079             case EDetailsView:
       
  1080             {
       
  1081                 if ( mFileDetails->mVideoEnabled && ! mFileDetails->mTvOutConnected )
       
  1082                 {
       
  1083                     mViewMode = viewMode;
       
  1084 
       
  1085                     //
       
  1086                     // Hack to clean up the screen before transition. We may not need it in NGA env
       
  1087                     //
       
  1088                     hideAllControls();
       
  1089 
       
  1090                     updateVideoRect( transitionEffect );
       
  1091                 }
       
  1092 
       
  1093                 break;
       
  1094             }
       
  1095             case EAudioOnlyView:
       
  1096             {
       
  1097                 if ( ! mFileDetails->mVideoEnabled || mFileDetails->mTvOutConnected )
       
  1098                 {
       
  1099                     mViewMode = viewMode;
       
  1100 
       
  1101                     mControlsConfig->updateControlList( EMPXControlCmdAudionOnlyViewOpened );
       
  1102                 }
       
  1103 
       
  1104                 break;
       
  1105             }
       
  1106             default:
       
  1107             {
       
  1108                 break;
       
  1109             }
       
  1110         }
       
  1111     }
       
  1112 }
       
  1113 
       
  1114 // -------------------------------------------------------------------------------------------------
       
  1115 //   QMPXVideoPlaybackControlsController::updateVideoRectDone
       
  1116 // -------------------------------------------------------------------------------------------------
       
  1117 //
       
  1118 void QMPXVideoPlaybackControlsController::updateVideoRectDone()
       
  1119 {
       
  1120     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRectDone()"));
       
  1121 
       
  1122     mViewTransitionIsGoingOn = false;
       
  1123 
       
  1124     TMPXVideoPlaybackControlCommandIds event = EMPXControlCmdFullScreenViewOpened;
       
  1125 
       
  1126     if ( mViewMode == EDetailsView )
       
  1127     {
       
  1128         event = EMPXControlCmdDetailsViewOpened;
       
  1129     }
       
  1130 
       
  1131     mControlsConfig->updateControlList( event );
       
  1132 }
       
  1133 
       
  1134 // -------------------------------------------------------------------------------------------------
       
  1135 //   QMPXVideoPlaybackControlsController::skipToPreviousVideoItem
       
  1136 // -------------------------------------------------------------------------------------------------
       
  1137 //
       
  1138 void QMPXVideoPlaybackControlsController::skipToPreviousVideoItem()
       
  1139 {
       
  1140     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::skipToPreviousVideoItem()"));
       
  1141 
       
  1142     handleCommand( EMPXPbvCmdPreviousListItem );
       
  1143 }
       
  1144 
       
  1145 // -------------------------------------------------------------------------------------------------
       
  1146 //   QMPXVideoPlaybackControlsController::skipToNextVideoItem
       
  1147 // -------------------------------------------------------------------------------------------------
       
  1148 //
       
  1149 void QMPXVideoPlaybackControlsController::skipToNextVideoItem()
       
  1150 {
       
  1151     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::skipToNextVideoItem()"));
       
  1152 
       
  1153     handleCommand( EMPXPbvCmdNextListItem );
       
  1154 }
       
  1155 
       
  1156 // -------------------------------------------------------------------------------------------------
       
  1157 //   QMPXVideoPlaybackControlsController::updateVideoRect()
       
  1158 // -------------------------------------------------------------------------------------------------
       
  1159 //
       
  1160 void QMPXVideoPlaybackControlsController::updateVideoRect( bool transitionEffect )
       
  1161 {
       
  1162     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRect()"));
       
  1163 
       
  1164     if ( mFileDetails->mVideoEnabled && ! mFileDetails->mTvOutConnected )
       
  1165     {
       
  1166         mViewTransitionIsGoingOn = true;
       
  1167 
       
  1168         QRectF rect;
       
  1169 
       
  1170         if ( mViewMode == EDetailsView )
       
  1171         {
       
  1172             QGraphicsWidget *parent = mLoader->findWidget( QString( "detailsPlaybackWindow" ) );
       
  1173             QGraphicsWidget *child = mLoader->findWidget( QString( "small_transparentWindow" ) );
       
  1174 
       
  1175             rect = parent->mapRectToScene( child->geometry() );
       
  1176         }
       
  1177         else if ( mViewMode == EFullScreenView )
       
  1178         {
       
  1179             QGraphicsWidget *widget = mLoader->findWidget( QString( "content" ) );
       
  1180             rect = widget->geometry();
       
  1181         }
       
  1182 
       
  1183         mViewWrapper->UpdateVideoRect( 
       
  1184                 rect.x(), rect.y(), rect.width(), rect.height(), transitionEffect );
       
  1185     }
       
  1186 }
       
  1187 
       
  1188 // -------------------------------------------------------------------------------------------------
       
  1189 //   QMPXVideoPlaybackControlsController::setDefaultBitmap()
       
  1190 // -------------------------------------------------------------------------------------------------
       
  1191 //
       
  1192 void QMPXVideoPlaybackControlsController::setDefaultBitmap()
       
  1193 {
       
  1194     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::setDefaultBitmap()"));
       
  1195 
       
  1196     //
       
  1197     // set specific bitmaps for audio only and tv out cases
       
  1198     // If we already requested a thumbnail, we will set the thumbnail after we receive the thumbnail
       
  1199     //
       
  1200     if ( mLoader && mThumbNailState != EThumbNailRequsted )
       
  1201     {
       
  1202         QGraphicsWidget *tvOutBitmap = mLoader->findWidget( "tvOutBitmap" );
       
  1203         tvOutBitmap->setVisible( false );
       
  1204 
       
  1205         QGraphicsWidget *realAudioOnlyBitmap = mLoader->findWidget( "realAudioOnlyBitmap" );
       
  1206         realAudioOnlyBitmap->setVisible( false );
       
  1207 
       
  1208         QGraphicsWidget *partialAudioOnlyBitmap = mLoader->findWidget( "partialAudioOnlyBitmap" );
       
  1209         partialAudioOnlyBitmap->setVisible( false );
       
  1210 
       
  1211         QGraphicsWidget *audioOnlyBitmap = mLoader->findWidget( "audioOnlyBitmap" );
       
  1212         audioOnlyBitmap->setVisible( false );
       
  1213 
       
  1214         if ( mFileDetails->mTvOutConnected )
       
  1215         {
       
  1216             tvOutBitmap->setVisible( true );
       
  1217         }
       
  1218         else if ( mFileDetails->mRNFormat ) 
       
  1219         {
       
  1220             realAudioOnlyBitmap->setVisible( true );
       
  1221         }
       
  1222         else if ( mFileDetails->mPartialPlayback )
       
  1223         {
       
  1224             partialAudioOnlyBitmap->setVisible( true );
       
  1225         }
       
  1226         else
       
  1227         {
       
  1228             audioOnlyBitmap->setVisible( true );
       
  1229         }
       
  1230     }    
       
  1231 }
       
  1232 
       
  1233 // -------------------------------------------------------------------------------------------------
       
  1234 //   QMPXVideoPlaybackControlsController::generateThumbNail()
       
  1235 // -------------------------------------------------------------------------------------------------
       
  1236 //
       
  1237 void QMPXVideoPlaybackControlsController::generateThumbNail()
       
  1238 {
       
  1239     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::generateThumbNail()"));
       
  1240 
       
  1241     //
       
  1242     // Generate thumbnail if it is local playback
       
  1243     //
       
  1244     if ( mFileDetails->mPlaybackMode == EMPXVideoLocal )
       
  1245     {
       
  1246         if ( mThumbNailState == EThumbNailEmpty )
       
  1247         {
       
  1248             mThumbnailManager = new ThumbnailManager(); ; 
       
  1249 
       
  1250             mThumbnailManager->setThumbnailSize( ThumbnailManager::ThumbnailLarge );
       
  1251             mThumbnailManager->setQualityPreference( ThumbnailManager::OptimizeForPerformance );
       
  1252          
       
  1253             if ( connect( mThumbnailManager, SIGNAL( thumbnailReady( QPixmap , void * , int , int ) ), 
       
  1254                           this, SLOT( handleThumbnailReady( QPixmap , void * , int , int ) ) ) )
       
  1255             {
       
  1256                 mThumbnailManager->getThumbnail( mFileDetails->mClipName );
       
  1257                 mThumbNailState = EThumbNailRequsted;
       
  1258             }
       
  1259         }
       
  1260     }
       
  1261     else
       
  1262     {
       
  1263         mThumbNailState = EThumbNailNotAvailable;
       
  1264     }
       
  1265 }
       
  1266 
       
  1267 // -------------------------------------------------------------------------------------------------
       
  1268 // QMPXVideoPlaybackControlsController::handleThumbnailReady()
       
  1269 // -------------------------------------------------------------------------------------------------
       
  1270 //
       
  1271 void QMPXVideoPlaybackControlsController::handleThumbnailReady( 
       
  1272         QPixmap tnData, void *internal , int id, int error )
       
  1273 {
       
  1274     Q_UNUSED( internal );
       
  1275     Q_UNUSED( id );
       
  1276 
       
  1277     if( ! error && mLoader )
       
  1278     {
       
  1279         QGraphicsWidget *tvOutBitmap = mLoader->findWidget( "tvOutBitmap" );
       
  1280         HbLabel *tvOutLabel = qobject_cast<HbLabel*>( tvOutBitmap );
       
  1281 
       
  1282         QIcon *qicon = new QIcon( tnData );
       
  1283 
       
  1284         HbIcon *hbIcon = new HbIcon( *qicon );
       
  1285         hbIcon->setSize( tvOutBitmap->size() );
       
  1286         tvOutLabel->setIcon( *hbIcon );
       
  1287 
       
  1288         if ( qicon )
       
  1289         {
       
  1290             delete qicon;
       
  1291         }
       
  1292 
       
  1293         if ( hbIcon )
       
  1294         {
       
  1295             delete hbIcon;
       
  1296         }
       
  1297 
       
  1298         mThumbNailState = EThumbNailSet;
       
  1299     }
       
  1300     else
       
  1301     {
       
  1302         mThumbNailState = EThumbNailNotAvailable;
       
  1303     }
       
  1304 
       
  1305     setDefaultBitmap();
       
  1306 
       
  1307     disconnect( mThumbnailManager, SIGNAL( thumbnailReady( QPixmap , void * , int , int ) ), 
       
  1308                 this, SLOT( handleThumbnailReady( QPixmap , void * , int , int ) ) );
       
  1309 }
       
  1310 
       
  1311 // End of File