videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackcontrolscontroller.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
     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#41 %
       
    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 <thumbnailmanager_qt.h>
       
    30 #include <xqserviceutil.h>
       
    31 
       
    32 #include <hblabel.h>
       
    33 #include <hbvolumesliderpopup.h>
       
    34 #include <hbtransparentwindow.h>
       
    35 #include <hbiconanimationmanager.h>
       
    36 #include <shareui.h>
       
    37 #include <hbinstance.h>
       
    38 #include <hbtapgesture.h>
       
    39 #include <hbpangesture.h>
       
    40 
       
    41 #include "mpxvideoviewwrapper.h"
       
    42 #include "hbvideobaseplaybackview.h"
       
    43 #include "mpxvideoplaybackcontrolbar.h"
       
    44 #include "mpxvideoplaybackcontrolpolicy.h"
       
    45 #include "mpxvideoplaybackdocumentloader.h"
       
    46 #include "mpxvideoplaybackviewfiledetails.h"
       
    47 #include "mpxvideoplaybackstatuspanecontrol.h"
       
    48 #include "mpxvideoplaybackfiledetailswidget.h"
       
    49 #include "mpxvideoplaybackfullscreencontrol.h"
       
    50 #include "mpxvideoplaybackcontrolscontroller.h"
       
    51 #include "mpxvideoplaybackcontrolconfiguration.h"
       
    52 #include "mpxvideoplaybackdetailsplaybackwindow.h"
       
    53 #include "videoservices.h"
       
    54 
       
    55 
       
    56 // ================= MEMBER FUNCTIONS ==============================================================
       
    57 
       
    58 // -------------------------------------------------------------------------------------------------
       
    59 // QMPXVideoPlaybackControlsController::QMPXVideoPlaybackControlsController()
       
    60 // -------------------------------------------------------------------------------------------------
       
    61 //
       
    62 QMPXVideoPlaybackControlsController::QMPXVideoPlaybackControlsController(
       
    63         HbVideoBasePlaybackView *view,
       
    64         CMPXVideoViewWrapper *viewWrapper,
       
    65         QMPXVideoPlaybackViewFileDetails *details )
       
    66     : mView( view )
       
    67     , mViewWrapper( viewWrapper )
       
    68     , mFileDetails( details )
       
    69     , mControlsPolicy( NULL )
       
    70     , mControlsConfig( NULL )
       
    71     , mControlsTimer( NULL )
       
    72     , mRNLogoTimer( NULL )
       
    73     , mLoader( NULL )
       
    74     , mVolumeControl( NULL )
       
    75     , mThumbnailManager( NULL )
       
    76     , mVideoServices( 0 )
       
    77     , mViewTransitionIsGoingOn( false )
       
    78     , mIsAttachOperation( false )
       
    79     , mThumbNailState( EThumbNailEmpty )
       
    80     , mState( EPbStateNotInitialised )
       
    81     , mViewMode( EFullScreenView )
       
    82 {
       
    83     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::QMPXVideoPlaybackControlsController()"));
       
    84 
       
    85     initializeController();
       
    86 }
       
    87 
       
    88 // -------------------------------------------------------------------------------------------------
       
    89 // QMPXVideoPlaybackControlsController::initializeController()
       
    90 // -------------------------------------------------------------------------------------------------
       
    91 //
       
    92 void QMPXVideoPlaybackControlsController::initializeController()
       
    93 {
       
    94     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::initializeController()"));
       
    95 
       
    96     mOrientation = hbInstance->allMainWindows()[0]->orientation();
       
    97     bool ok = connect( hbInstance->allMainWindows()[0], SIGNAL( orientationChanged( Qt::Orientation ) ),
       
    98                        this, SLOT( handleOrientationChanged( Qt::Orientation ) ) );
       
    99 
       
   100     MPX_DEBUG(
       
   101         _L("QMPXVideoPlaybackControlsController::initializeController() orientation = %d, ok =%d"),
       
   102         mOrientation, ok );
       
   103 
       
   104     setParent( mView );
       
   105 
       
   106     mView->hideItems( Hb::AllItems );
       
   107 
       
   108     //
       
   109     // Create layout loader
       
   110     //
       
   111     ok = false;
       
   112     mLoader = new QMPXVideoPlaybackDocumentLoader( this );
       
   113     mLoader->load( KMPXPLAYBACKVIEW_XML, &ok );
       
   114 
       
   115     if ( ok )
       
   116     {
       
   117         QGraphicsWidget *widget = mLoader->findWidget( QString( "content" ) );
       
   118         mView->setWidget( widget );
       
   119     }
       
   120     else
       
   121     {
       
   122         MPX_DEBUG(
       
   123                 _L("QMPXVideoPlaybackControlsController::initializeController()- can't find xml"));
       
   124 
       
   125         //
       
   126         // Can't find xml for layout. Delete mLoader
       
   127         //
       
   128         delete mLoader;
       
   129         mLoader = NULL;
       
   130     }
       
   131 
       
   132     mFileDetails->mRNFormat = realFormat( mFileDetails->mClipName );
       
   133 
       
   134     //
       
   135     // Controls dismissing timer
       
   136     //
       
   137     mControlsTimer = new QTimer( this );
       
   138     mControlsTimer->setInterval( KMPXControlsTimeOut );
       
   139     mControlsTimer->setSingleShot( false );
       
   140     connect( mControlsTimer, SIGNAL( timeout() ), this, SLOT( hideAllControls() ) );
       
   141 
       
   142     mControlsPolicy = new QMPXVideoPlaybackControlPolicy();
       
   143 
       
   144     mControlsConfig = new QMPXVideoPlaybackControlConfiguration( this );
       
   145     connect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
       
   146     mControlsConfig->createControlList();
       
   147 
       
   148     //
       
   149     // Create volume popup control
       
   150     //
       
   151     mVolumeControl = new HbVolumeSliderPopup();
       
   152     mVolumeControl->setVisible( false );
       
   153     mVolumeControl->setTimeout( KMPXControlsTimeOut );
       
   154     mVolumeControl->setTickPosition( Hb::NoSliderTicks );
       
   155     mVolumeControl->setRange( KPbPlaybackVolumeLevelMin, KPbPlaybackVolumeLevelMax );
       
   156 
       
   157     //
       
   158     // grab tap gesture
       
   159     //
       
   160     mView->grabGesture( Qt::TapGesture );
       
   161     connect( mView, SIGNAL( tappedOnScreen() ), this, SLOT( handleTappedOnScreen() ) );
       
   162 
       
   163     //
       
   164     // grab pan gesture for playlist
       
   165     //
       
   166     if ( mFileDetails->mMultiItemPlaylist )
       
   167     {
       
   168         mView->grabGesture( Qt::PanGesture );
       
   169         connect( mView, SIGNAL( pannedToRight() ), this, SLOT( skipToPreviousVideoItem() ) );
       
   170         connect( mView, SIGNAL( pannedToLeft() ), this, SLOT( skipToNextVideoItem() ) );
       
   171     }
       
   172 
       
   173     //
       
   174     // if videoplayback is in service mode, create a videoservices instance
       
   175     //
       
   176     if ( XQServiceUtil::isService() && ! mVideoServices )
       
   177     {
       
   178         //
       
   179         // obtain VideoServices instance
       
   180         //
       
   181         mVideoServices = VideoServices::instance();
       
   182 
       
   183         //
       
   184         // allow 'attach' operation only for non-streaming media clips
       
   185         //
       
   186         if ( mVideoServices && mFileDetails->mPlaybackMode == EMPXVideoLocal )
       
   187         {
       
   188             //
       
   189             // determine if this is 'attach' operation
       
   190             //
       
   191             mIsAttachOperation = ( mVideoServices->currentService() == VideoServices::EUriFetcher );
       
   192 
       
   193             if ( mIsAttachOperation )
       
   194             {
       
   195                 //
       
   196                 // connect signal filePath() to videoservices slot itemSelected()
       
   197                 //
       
   198                 connect( this, SIGNAL( attachVideoPath( const QString& ) ),
       
   199                          mVideoServices, SLOT( itemSelected( const QString& ) ) );
       
   200             }
       
   201         }
       
   202     }
       
   203 }
       
   204 
       
   205 // -------------------------------------------------------------------------------------------------
       
   206 // QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController
       
   207 // -------------------------------------------------------------------------------------------------
       
   208 //
       
   209 QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController()
       
   210 {
       
   211     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController()"));
       
   212 
       
   213     mView->ungrabGesture( Qt::TapGesture );
       
   214     disconnect( mView, SIGNAL( tappedOnScreen() ), this, SLOT( handleTappedOnScreen() ) );
       
   215 
       
   216     if ( mFileDetails->mMultiItemPlaylist )
       
   217     {
       
   218         mView->ungrabGesture( Qt::PanGesture );
       
   219 
       
   220         disconnect( mView, SIGNAL( pannedToRight() ), this, SLOT( skipToNextVideoItem() ) );
       
   221         disconnect( mView, SIGNAL( pannedToLeft() ), this, SLOT( skipToPreviousVideoItem() ) );
       
   222     }
       
   223 
       
   224     disconnect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
       
   225     disconnect( mControlsTimer, SIGNAL( timeout() ), this, SLOT( hideAllControls() ) );
       
   226     disconnect( hbInstance->allMainWindows()[0], SIGNAL( orientationChanged( Qt::Orientation ) ),
       
   227                 this, SLOT( handleOrientationChanged( Qt::Orientation ) ) );
       
   228 
       
   229     mView->setWidget( NULL );
       
   230 
       
   231     mControls.clear();
       
   232 
       
   233     if ( mControlsTimer )
       
   234     {
       
   235         delete mControlsTimer;
       
   236         mControlsTimer = NULL;
       
   237     }
       
   238 
       
   239     if ( mRNLogoTimer )
       
   240     {
       
   241         disconnect( mRNLogoTimer, SIGNAL( timeout() ), this, SLOT( handleRNLogoTimeout() ) );
       
   242 
       
   243         delete mRNLogoTimer;
       
   244         mRNLogoTimer = NULL;
       
   245     }
       
   246 
       
   247     if ( mControlsPolicy )
       
   248     {
       
   249         delete mControlsPolicy;
       
   250         mControlsPolicy = NULL;
       
   251     }
       
   252 
       
   253     if ( mControlsConfig )
       
   254     {
       
   255         delete mControlsConfig;
       
   256         mControlsConfig = NULL;
       
   257     }
       
   258 
       
   259     if ( mLoader )
       
   260     {
       
   261         delete mLoader;
       
   262         mLoader = NULL;
       
   263     }
       
   264 
       
   265     if ( mThumbnailManager )
       
   266     {
       
   267         delete mThumbnailManager;
       
   268         mThumbnailManager = NULL;
       
   269     }
       
   270 
       
   271     if ( mVolumeControl )
       
   272     {
       
   273         delete mVolumeControl;
       
   274         mVolumeControl = NULL;
       
   275     }
       
   276 
       
   277     if ( mIsAttachOperation )
       
   278     {
       
   279         //
       
   280         // disable connection for 'attach' operation
       
   281         //
       
   282         disconnect( this, SIGNAL( attachVideoPath( const QString& ) ),
       
   283                     mVideoServices, SLOT( itemSelected( const QString& ) ) );
       
   284     }
       
   285 
       
   286     if ( mVideoServices )
       
   287     {
       
   288         //
       
   289         // decrease videoservices instance count
       
   290         //
       
   291     	mVideoServices->decreaseReferenceCount();
       
   292     	mVideoServices = 0;
       
   293     }
       
   294 }
       
   295 
       
   296 // -------------------------------------------------------------------------------------------------
       
   297 // QMPXVideoPlaybackControlsController::addFileDetails()
       
   298 // -------------------------------------------------------------------------------------------------
       
   299 //
       
   300 void QMPXVideoPlaybackControlsController::addFileDetails(
       
   301     QMPXVideoPlaybackViewFileDetails* details )
       
   302 {
       
   303     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::addFileDetails"));
       
   304 
       
   305     mFileDetails = details;
       
   306 
       
   307     mFileDetails->mRNFormat = realFormat( mFileDetails->mClipName );
       
   308 
       
   309     mControlsConfig->updateControlsWithFileDetails();
       
   310 
       
   311     //
       
   312     // for audio-only clips and tv-out, default view is flip view
       
   313     //
       
   314     if ( ! details->mVideoEnabled )
       
   315     {
       
   316         changeViewMode( EAudioOnlyView, false );
       
   317     }
       
   318 
       
   319     if ( details->mTvOutConnected )
       
   320     {
       
   321         handleEvent( EMPXControlCmdTvOutConnected );
       
   322     }
       
   323 
       
   324     //
       
   325     // Dimmed the volume control if it is video only
       
   326     //
       
   327     if ( ! mFileDetails->mAudioEnabled )
       
   328     {
       
   329         mVolumeControl->setValue( 0 );
       
   330         mVolumeControl->setEnabled( false );
       
   331     }
       
   332 }
       
   333 
       
   334 // -------------------------------------------------------------------------------------------------
       
   335 // QMPXVideoPlaybackControlsController::handleEvent
       
   336 // -------------------------------------------------------------------------------------------------
       
   337 //
       
   338 void QMPXVideoPlaybackControlsController::handleEvent(
       
   339     TMPXVideoPlaybackControlCommandIds event, int value )
       
   340 {
       
   341     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::handleEvent(%d)"), event);
       
   342 
       
   343     switch ( event )
       
   344     {
       
   345         case EMPXControlCmdSetPosition:
       
   346         {
       
   347             MPX_DEBUG(_L("    [EMPXControlCmdSetPosition [%d]]"), value );
       
   348 
       
   349             positionChanged( (qreal)value / (qreal)KPbMilliMultiplier);
       
   350             break;
       
   351         }
       
   352         case EMPXControlCmdSetDuration:
       
   353         {
       
   354             MPX_DEBUG(_L("    [EMPXControlCmdSetDuration [%d]]"), value );
       
   355 
       
   356             durationChanged( (qreal)value / (qreal)KPbMilliMultiplier );
       
   357             break;
       
   358         }
       
   359         case EMPXControlCmdStateChanged:
       
   360         {
       
   361             MPX_DEBUG(_L("    [EMPXControlCmdStateChanged]"));
       
   362 
       
   363             handleStateChange( (TMPXPlaybackState)value );
       
   364             break;
       
   365         }
       
   366         case EMPXControlCmdSetVolume:
       
   367         {
       
   368             MPX_DEBUG(_L("    [EMPXControlCmdSetVolume [%d]]"), value );
       
   369 
       
   370             volumeChanged( value );
       
   371             break;
       
   372         }
       
   373         case EMPXControlCmdSetAspectRatio:
       
   374         {
       
   375             MPX_DEBUG(_L("    [EMPXControlCmdSetAspectRatio %d]"), value );
       
   376 
       
   377             aspectRatioChanged( value );
       
   378 
       
   379             break;
       
   380         }
       
   381         case EMPXControlCmdSetDownloadSize:
       
   382         {
       
   383             MPX_DEBUG(_L("    [EMPXControlCmdSetDownloadSize [%d]]"), value );
       
   384             setDownloadSize( value );
       
   385             break;
       
   386         }
       
   387         case EMPXControlCmdDownloadUpdated:
       
   388         {
       
   389             MPX_DEBUG(_L("    [EMPXControlCmdDownloadUpdated [%d]]"), value );
       
   390             updateDownloadPosition( value );
       
   391             break;
       
   392         }
       
   393         case EMPXControlCmdDownloadComplete:
       
   394         {
       
   395             MPX_DEBUG(_L("    [EMPXControlCmdDownloadComplete [%d]]"), value);
       
   396             updateDownloadPosition( value );
       
   397             break;
       
   398         }
       
   399         case EMPXControlCmdSetDownloadPaused:
       
   400         case EMPXControlCmdClearDownloadPaused:
       
   401         {
       
   402             mControlsConfig->updateControlList( event );
       
   403             break;
       
   404         }
       
   405         case EMPXControlCmdTvOutConnected:
       
   406         {
       
   407             MPX_DEBUG(_L("    [EMPXControlCmdTvOutConnected]"));
       
   408 
       
   409             handleTvOutEvent( true, event );
       
   410             break;
       
   411         }
       
   412         case EMPXControlCmdTvOutDisconnected:
       
   413         {
       
   414             MPX_DEBUG(_L("    [EMPXControlCmdTvOutDisConnected]"));
       
   415 
       
   416             handleTvOutEvent( false, event );
       
   417             break;
       
   418         }
       
   419         case EMPXControlCmdHandleErrors:
       
   420         {
       
   421             MPX_DEBUG(_L("    [EMPXControlCmdHandleErrors]"));
       
   422 
       
   423             handleErrors();
       
   424 
       
   425             break;
       
   426         }
       
   427         case EMPXControlCmdShowVolumeControls:
       
   428         {
       
   429             MPX_DEBUG(_L("    [EMPXControlCmdShowVolumeControls]"));
       
   430 
       
   431             showVolumeControls();
       
   432             break;
       
   433         }
       
   434     }
       
   435 }
       
   436 
       
   437 // -------------------------------------------------------------------------------------------------
       
   438 // QMPXVideoPlaybackControlsController::handleStateChange
       
   439 // -------------------------------------------------------------------------------------------------
       
   440 //
       
   441 void QMPXVideoPlaybackControlsController::handleStateChange( TMPXPlaybackState newState )
       
   442 {
       
   443     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleStateChange()"),
       
   444                    _L("new state = %d"), newState );
       
   445 
       
   446     //
       
   447     // Somehow EPbStatePlaying, EPbStatePaused gets called twice continously
       
   448     //
       
   449     if ( newState != mState )
       
   450     {
       
   451         mState = newState;
       
   452 
       
   453         switch ( newState )
       
   454         {
       
   455             case EPbStatePlaying:
       
   456             case EPbStateInitialising:
       
   457             case EPbStateBuffering:
       
   458             case EPbStatePaused:
       
   459             case EPbStateNotInitialised:
       
   460             {
       
   461                 //
       
   462                 //  Show all the controls
       
   463                 //
       
   464                 showControls();
       
   465 
       
   466                 updateState();
       
   467 
       
   468                 break;
       
   469             }
       
   470             default:
       
   471             {
       
   472                 break;
       
   473             }
       
   474         }
       
   475     }
       
   476 }
       
   477 
       
   478 // -------------------------------------------------------------------------------------------------
       
   479 // QMPXVideoPlaybackControlsController::controlsListUpdated()
       
   480 // -------------------------------------------------------------------------------------------------
       
   481 //
       
   482 void QMPXVideoPlaybackControlsController::controlsListUpdated()
       
   483 {
       
   484     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::controlsListUpdated()"));
       
   485 
       
   486     hideAllControls();
       
   487 
       
   488     QList<TMPXVideoPlaybackControls>& updatedList = mControlsConfig->controlList();
       
   489 
       
   490     QList<TMPXVideoPlaybackControls> myList = updatedList;
       
   491 
       
   492     int controlCount = mControls.count();
       
   493 
       
   494     int i = 0 ;
       
   495     int index = KErrNotFound;
       
   496 
       
   497 
       
   498     for ( int iCnt = 0 ; iCnt < controlCount ; iCnt++ )
       
   499     {
       
   500         index = myList.indexOf( mControls[i]->controlIndex() );
       
   501 
       
   502         if ( index == KErrNotFound )
       
   503         {
       
   504             //
       
   505             //  Delete control since it doesn't exist in new list
       
   506             //
       
   507             mControls.removeAt( i );
       
   508         }
       
   509         else
       
   510         {
       
   511             //
       
   512             //  Control exists in new list.
       
   513             //  Update the policy property based on file details and view mode to the controls
       
   514             //
       
   515             TUint properties = 0;
       
   516             mControlsPolicy->setControlProperties(
       
   517                     mControls[i]->controlIndex(), properties, mFileDetails, mViewMode );
       
   518             mControls[i]->updateControlProperties( properties );
       
   519 
       
   520             //
       
   521             //  Control exists in new list.
       
   522             //
       
   523             myList.removeAt( index );
       
   524             i++;
       
   525         }
       
   526     }
       
   527 
       
   528     //
       
   529     //  The updated list will contain added controls only
       
   530     //
       
   531     for ( int j = 0 ; j < myList.count() ; j++ )
       
   532     {
       
   533         appendControl( myList[j] );
       
   534     }
       
   535 
       
   536     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   537     {
       
   538         mControls[i]->updateControlsWithFileDetails( mFileDetails );
       
   539     }
       
   540 
       
   541     showControls();
       
   542 }
       
   543 
       
   544 // -------------------------------------------------------------------------------------------------
       
   545 // QMPXVideoPlaybackControlsController::appendControl()
       
   546 // -------------------------------------------------------------------------------------------------
       
   547 //
       
   548 void QMPXVideoPlaybackControlsController::appendControl( TMPXVideoPlaybackControls controlIndex )
       
   549 {
       
   550     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::appendControl()"),
       
   551                    _L("control index = %d"), controlIndex );
       
   552 
       
   553     TUint properties = 0;
       
   554 
       
   555     mControlsPolicy->setControlProperties( controlIndex, properties, mFileDetails, mViewMode );
       
   556     QMPXVideoPlaybackFullScreenControl* control;
       
   557 
       
   558     switch ( controlIndex )
       
   559     {
       
   560         case EMPXBufferingAnimation:
       
   561         {
       
   562             //
       
   563             // Load animation icons
       
   564             //
       
   565             QString animationName = ":/hbvideoplaybackview/animations/";
       
   566 
       
   567             if ( mFileDetails->mRNFormat )
       
   568             {
       
   569                 animationName.append( "rn_preroll_anim.axml" );
       
   570             }
       
   571             else
       
   572             {
       
   573                 animationName.append( "generic_preroll_anim.axml" );
       
   574             }
       
   575 
       
   576             HbIconAnimationManager* manager = HbIconAnimationManager::global();
       
   577             bool ok = manager->addDefinitionFile( animationName );
       
   578 
       
   579             MPX_DEBUG(_L("    EMPXBufferingAnimation add animation definition ok = %d"), ok);
       
   580 
       
   581             //
       
   582             // Buffering animation icon
       
   583             //
       
   584             QGraphicsWidget *widget = mLoader->findWidget( QString( "bufferingIcon" ) );
       
   585             HbLabel *bufferingAnim = qobject_cast<HbLabel*>( widget );
       
   586 
       
   587             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   588                                                               controlIndex,
       
   589                                                               bufferingAnim,
       
   590                                                               properties );
       
   591             mControls.append( control );
       
   592 
       
   593             break;
       
   594         }
       
   595         case EMPXStatusPane:
       
   596         {
       
   597             //
       
   598             // Status key (signal + title + back key)
       
   599             //
       
   600             control = new QMPXVideoPlaybackStatusPaneControl( this,
       
   601                                                               controlIndex,
       
   602                                                               NULL,
       
   603                                                               properties );
       
   604             mControls.append( control );
       
   605 
       
   606             break;
       
   607         }
       
   608         case EMPXControlBar:
       
   609         {
       
   610             //
       
   611             // Button bar
       
   612             //
       
   613             QGraphicsWidget *widget = mLoader->findWidget( QString( "controlBarLayout" ) );
       
   614             QMPXVideoPlaybackControlBar *controlBar =
       
   615                 qobject_cast<QMPXVideoPlaybackControlBar*>( widget );
       
   616             controlBar->initialize();
       
   617 
       
   618             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   619                                                               controlIndex,
       
   620                                                               controlBar,
       
   621                                                               properties );
       
   622             mControls.append( control );
       
   623 
       
   624             break;
       
   625         }
       
   626         case EMPXFileDetailsWidget:
       
   627         {
       
   628             QGraphicsWidget *widget = mLoader->findWidget( QString( "fileDetailsLayout" ) );
       
   629             QMPXVideoPlaybackFileDetailsWidget *fileDetails =
       
   630                 qobject_cast<QMPXVideoPlaybackFileDetailsWidget*>( widget );
       
   631 
       
   632             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   633                                                               controlIndex,
       
   634                                                               fileDetails,
       
   635                                                               properties );
       
   636 
       
   637             mControls.append( control );
       
   638             break;
       
   639         }
       
   640         case EMPXIndicatorBitmap:
       
   641         {
       
   642             QGraphicsWidget *widget = mLoader->findWidget( QString( "bitmapLayout" ) );
       
   643             HbWidget *bitmapWidget = qobject_cast<HbWidget*>( widget );
       
   644 
       
   645             setDefaultBitmap();
       
   646             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   647                                                               controlIndex,
       
   648                                                               bitmapWidget,
       
   649                                                               properties );
       
   650             mControls.append( control );
       
   651 
       
   652             break;
       
   653         }
       
   654         case EMPXRealLogoBitmap:
       
   655         {
       
   656             QGraphicsWidget *widget = mLoader->findWidget( QString( "rnLogoBitmap" ) );
       
   657             HbWidget *bitmapWidget = qobject_cast<HbWidget*>( widget );
       
   658 
       
   659             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   660                                                               controlIndex,
       
   661                                                               bitmapWidget,
       
   662                                                               properties );
       
   663             mControls.append( control );
       
   664 
       
   665             connect( bitmapWidget, SIGNAL( visibleChanged() ),
       
   666                      this, SLOT( handleRNLogoVisibleChanged() ) );
       
   667 
       
   668             break;
       
   669         }
       
   670         case EMPXDetailsViewPlaybackWindow:
       
   671         {
       
   672             QGraphicsWidget *widget = mLoader->findWidget( QString( "detailsPlaybackWindow" ) );
       
   673             QMPXVideoPlaybackDetailsPlaybackWindow *detailsPlaybackWindow =
       
   674                     qobject_cast<QMPXVideoPlaybackDetailsPlaybackWindow*>( widget );
       
   675             detailsPlaybackWindow->initialize();
       
   676 
       
   677             control = new QMPXVideoPlaybackFullScreenControl( this,
       
   678                                                               controlIndex,
       
   679                                                               detailsPlaybackWindow,
       
   680                                                               properties );
       
   681             mControls.append( control );
       
   682 
       
   683             break;
       
   684         }
       
   685     }
       
   686 }
       
   687 
       
   688 // -------------------------------------------------------------------------------------------------
       
   689 // QMPXVideoPlaybackControlsController::handleTappedOnScreen()
       
   690 // -------------------------------------------------------------------------------------------------
       
   691 //
       
   692 void QMPXVideoPlaybackControlsController::handleTappedOnScreen()
       
   693 
       
   694 {
       
   695     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleTappedOnScreen()"));
       
   696 
       
   697     //
       
   698     // If we are in full screen view, toggle the visibility when playing and paused
       
   699     // If we are in details view, issue playpause
       
   700     // If we are in audio only view, ignore
       
   701     //
       
   702     switch( mViewMode )
       
   703     {
       
   704         case EFullScreenView:
       
   705         {
       
   706             if ( mState == EPbStatePlaying || mState == EPbStatePaused )
       
   707             {
       
   708                 if ( isVisible() )
       
   709                 {
       
   710                     //
       
   711                     // If the volume control is visible, hide it
       
   712                     //
       
   713                     if ( mVolumeControl->isVisible() )
       
   714                     {
       
   715                         mVolumeControl->setVisible( false );
       
   716                     }
       
   717 
       
   718                     hideAllControls();
       
   719                 }
       
   720                 else
       
   721                 {
       
   722                     showControls();
       
   723                 }
       
   724             }
       
   725 
       
   726             break;
       
   727         }
       
   728         case EDetailsView:
       
   729         {
       
   730             handleCommand( EMPXPbvCmdPlayPause );
       
   731 
       
   732             break;
       
   733         }
       
   734     }
       
   735 }
       
   736 
       
   737 // -------------------------------------------------------------------------------------------------
       
   738 // QMPXVideoPlaybackControlsController::resetDisappearingTimers()
       
   739 // -------------------------------------------------------------------------------------------------
       
   740 //
       
   741 void QMPXVideoPlaybackControlsController::resetDisappearingTimers( TMPXTimerAction timerAction )
       
   742 {
       
   743     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::resetDisappearingTimers()"));
       
   744 
       
   745     if ( mControlsTimer->isActive() )
       
   746     {
       
   747         mControlsTimer->stop();
       
   748     }
       
   749 
       
   750     //
       
   751     //  Do not start the time for DetailsView and AudioOnlyView
       
   752     //
       
   753     if ( timerAction == EMPXTimerReset &&
       
   754          mState == EPbStatePlaying &&
       
   755          mViewMode == EFullScreenView )
       
   756     {
       
   757         MPX_DEBUG(_L("    Starting Controls Timer"));
       
   758 
       
   759         mControlsTimer->start();
       
   760     }
       
   761 }
       
   762 
       
   763 // -------------------------------------------------------------------------------------------------
       
   764 //   QMPXVideoPlaybackControlsController::hideAllControls()
       
   765 // -------------------------------------------------------------------------------------------------
       
   766 //
       
   767 void QMPXVideoPlaybackControlsController::hideAllControls()
       
   768 {
       
   769     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::hideControls()"));
       
   770 
       
   771     resetDisappearingTimers( EMPXTimerCancel );
       
   772 
       
   773     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   774     {
       
   775         mControls[i]->setVisible( false );
       
   776     }
       
   777 }
       
   778 
       
   779 // -------------------------------------------------------------------------------------------------
       
   780 //   QMPXVideoPlaybackControlsController::showControls()
       
   781 // -------------------------------------------------------------------------------------------------
       
   782 //
       
   783 void QMPXVideoPlaybackControlsController::showControls()
       
   784 {
       
   785     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::showControls()"));
       
   786 
       
   787     resetDisappearingTimers( EMPXTimerReset );
       
   788 
       
   789     if ( ! mViewTransitionIsGoingOn && mOrientation == Qt::Horizontal )
       
   790     {
       
   791         for ( int i = 0 ; i < mControls.count() ; i++ )
       
   792         {
       
   793             mControls[i]->setVisibility( mState );
       
   794         }
       
   795     }
       
   796 }
       
   797 
       
   798 // -------------------------------------------------------------------------------------------------
       
   799 //   QMPXVideoPlaybackControlsController::isVisible()
       
   800 // -------------------------------------------------------------------------------------------------
       
   801 //
       
   802 bool QMPXVideoPlaybackControlsController::isVisible()
       
   803 {
       
   804     bool visible = false;
       
   805 
       
   806     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   807     {
       
   808         if ( mControls[i]->controlIndex() == EMPXControlBar )
       
   809         {
       
   810             if ( mControls[i]->isVisible() )
       
   811             {
       
   812                 visible = true;
       
   813             }
       
   814 
       
   815             break;
       
   816         }
       
   817     }
       
   818 
       
   819     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isVisible() [%d]"), visible);
       
   820 
       
   821     return visible;
       
   822 }
       
   823 
       
   824 // -------------------------------------------------------------------------------------------------
       
   825 //   QMPXVideoPlaybackControlsController::handleCommand()
       
   826 // -------------------------------------------------------------------------------------------------
       
   827 //
       
   828 void QMPXVideoPlaybackControlsController::handleCommand(
       
   829         TMPXVideoPlaybackViewCommandIds command, int value )
       
   830 {
       
   831     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::handleCommand(%d)"), command);
       
   832 
       
   833     switch( command )
       
   834     {
       
   835         case EMPXPbvCmdSetPosition:
       
   836         {
       
   837             TRAP_IGNORE( mViewWrapper->SetPropertyL( EPbPropertyPosition,
       
   838                                                      value * KPbMilliMultiplier ) );
       
   839             break;
       
   840         }
       
   841         case EMPXPbvCmdSetVolume:
       
   842         {
       
   843             TRAP_IGNORE( mViewWrapper->SetPropertyL( EPbPropertyVolume, value ) );
       
   844             break;
       
   845         }
       
   846         default:
       
   847         {
       
   848             TRAP_IGNORE( mViewWrapper->HandleCommandL( command ) );
       
   849             break;
       
   850         }
       
   851     }
       
   852 }
       
   853 
       
   854 // -------------------------------------------------------------------------------------------------
       
   855 //   QMPXVideoPlaybackControlsController::volumeChanged()
       
   856 // -------------------------------------------------------------------------------------------------
       
   857 //
       
   858 void QMPXVideoPlaybackControlsController::volumeChanged( int volume )
       
   859 {
       
   860     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::volumeChanged() [%d]"), volume);
       
   861 
       
   862     if ( mVolumeControl )
       
   863     {
       
   864         mVolumeControl->setValue( volume );
       
   865     }
       
   866 }
       
   867 
       
   868 // -------------------------------------------------------------------------------------------------
       
   869 //   QMPXVideoPlaybackControlsController::showVolumeControls()
       
   870 // -------------------------------------------------------------------------------------------------
       
   871 //
       
   872 void QMPXVideoPlaybackControlsController::showVolumeControls()
       
   873 {
       
   874     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::showVolumeControls()"));
       
   875 
       
   876     if ( mVolumeControl )
       
   877     {
       
   878         mVolumeControl->setVisible( true );
       
   879     }
       
   880 }
       
   881 
       
   882 // -------------------------------------------------------------------------------------------------
       
   883 //   QMPXVideoPlaybackControlsController::durationChanged()
       
   884 // -------------------------------------------------------------------------------------------------
       
   885 //
       
   886 void QMPXVideoPlaybackControlsController::durationChanged( int duration )
       
   887 {
       
   888     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::durationChanged() [%d]"), duration);
       
   889 
       
   890     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   891     {
       
   892         if ( mControls[i]->durationChanged( duration ) )
       
   893         {
       
   894             break;
       
   895         }
       
   896     }
       
   897 }
       
   898 
       
   899 // -------------------------------------------------------------------------------------------------
       
   900 //   QMPXVideoPlaybackControlsController::positionChanged()
       
   901 // -------------------------------------------------------------------------------------------------
       
   902 //
       
   903 void QMPXVideoPlaybackControlsController::positionChanged( int position )
       
   904 {
       
   905     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::positionChanged() [%d]"), position);
       
   906 
       
   907     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   908     {
       
   909         if ( mControls[i]->positionChanged( position ) )
       
   910         {
       
   911             break;
       
   912         }
       
   913     }
       
   914 }
       
   915 
       
   916 // -------------------------------------------------------------------------------------------------
       
   917 //   QMPXVideoPlaybackControlsController::aspectRatioChanged()
       
   918 // -------------------------------------------------------------------------------------------------
       
   919 //
       
   920 void QMPXVideoPlaybackControlsController::aspectRatioChanged( int aspectRatio )
       
   921 {
       
   922     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::aspectRatioChanged() [%d]"), aspectRatio);
       
   923 
       
   924     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   925     {
       
   926         if ( mControls[i]->aspectRatioChanged( aspectRatio ) )
       
   927         {
       
   928             break;
       
   929         }
       
   930     }
       
   931 }
       
   932 
       
   933 // -------------------------------------------------------------------------------------------------
       
   934 //   QMPXVideoPlaybackControlsController::updateState()
       
   935 // -------------------------------------------------------------------------------------------------
       
   936 //
       
   937 void QMPXVideoPlaybackControlsController::updateState()
       
   938 {
       
   939     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateState() [%d]"), mState);
       
   940 
       
   941     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   942     {
       
   943         mControls[i]->updateState( mState );
       
   944     }
       
   945 }
       
   946 
       
   947 // -------------------------------------------------------------------------------------------------
       
   948 // QMPXVideoPlaybackControlsController::realFormat()
       
   949 // -------------------------------------------------------------------------------------------------
       
   950 //
       
   951 bool QMPXVideoPlaybackControlsController::realFormat( QString filename )
       
   952 {
       
   953     bool realFormat = false;
       
   954 
       
   955     if ( !filename.isNull() && !filename.isEmpty() )
       
   956     {
       
   957         if ( mFileDetails->mPlaybackMode == EMPXVideoStreaming ||
       
   958              mFileDetails->mPlaybackMode == EMPXVideoLiveStreaming )
       
   959         {
       
   960             TBufC<255> file(filename.utf16());
       
   961             realFormat = realFormatForStreaming( file );
       
   962         }
       
   963         else
       
   964         {
       
   965             realFormat = realFormatForLocal();
       
   966         }
       
   967     }
       
   968 
       
   969     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::realFormat() [%d]"), realFormat);
       
   970 
       
   971     return realFormat;
       
   972 }
       
   973 
       
   974 // -------------------------------------------------------------------------------------------------
       
   975 // QMPXVideoPlaybackControlsController::realFormatForStreaming()
       
   976 // -------------------------------------------------------------------------------------------------
       
   977 //
       
   978 bool QMPXVideoPlaybackControlsController::realFormatForStreaming( const TDesC& des )
       
   979 {
       
   980     bool realFormat = false;
       
   981     TParse filePath;
       
   982 
       
   983     _LIT(KMPXRMEXT, ".R" );
       
   984 
       
   985     int err = filePath.Set( des, NULL, NULL );
       
   986 
       
   987     //
       
   988     // It is valid to have a "\" character in a url, but parsing fails,
       
   989     // switch these characters to "/" for the local string and try parsing again.
       
   990     //
       
   991     if ( err == KErrBadName )
       
   992     {
       
   993         int backsashPos = des.LocateF('\\');
       
   994 
       
   995         if( backsashPos != KErrNotFound )
       
   996         {
       
   997             HBufC* fileName = NULL;
       
   998 
       
   999             TRAP( err,  fileName = des.AllocL() );
       
  1000 
       
  1001             if ( err == KErrNone )
       
  1002             {
       
  1003                 int count( fileName->Des().Length() );
       
  1004 
       
  1005                 for ( int j = backsashPos ; j < count; ++j )
       
  1006                 {
       
  1007                     if ( fileName->Des()[j]== '\\' )
       
  1008                     {
       
  1009                         fileName->Des()[j]='/';
       
  1010                     }
       
  1011                 }
       
  1012                 err = filePath.Set( fileName->Des(), NULL, NULL );
       
  1013             }
       
  1014 
       
  1015             if ( fileName )
       
  1016             {
       
  1017                 delete fileName;
       
  1018                 fileName = NULL;
       
  1019             }
       
  1020         }
       
  1021     }
       
  1022 
       
  1023     if ( err == KErrNone )
       
  1024     {
       
  1025         //
       
  1026         // The requirement to support arguments with the extension in streaming links
       
  1027         // for-ex: /video.3gp?start=10&end=40 will have to supported
       
  1028         // as well. So just by doing p.Ext() would retrieve all the string
       
  1029         // after "." so by doing a Left(2) would retrieve only
       
  1030         // .3g or .rm and so on. This would help better
       
  1031         // interpret the extension and decide the branding accordingly
       
  1032         //
       
  1033         filePath.Set( filePath.NameAndExt(), NULL, NULL );
       
  1034         TPtrC extension = filePath.Ext().Left( 2 );
       
  1035 
       
  1036         TBuf<2> buf;
       
  1037         buf.Format( extension );
       
  1038         buf.UpperCase();
       
  1039 
       
  1040         // RealMedia Branding
       
  1041         if ( ! buf.Compare( KMPXRMEXT ) )
       
  1042         {
       
  1043             realFormat = true;
       
  1044         }
       
  1045     }
       
  1046 
       
  1047     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::realFormatForStreaming()[%d]"), realFormat);
       
  1048 
       
  1049     return realFormat;
       
  1050 }
       
  1051 
       
  1052 // -------------------------------------------------------------------------------------------------
       
  1053 // QMPXVideoPlaybackControlsController::realFormatForLocal()
       
  1054 // -------------------------------------------------------------------------------------------------
       
  1055 //
       
  1056 bool QMPXVideoPlaybackControlsController::realFormatForLocal()
       
  1057 {
       
  1058     bool realFormat = false;
       
  1059 
       
  1060     QString real( "real" );
       
  1061     QString rn( "rn" );
       
  1062 
       
  1063     if ( mFileDetails->mMimeType.contains( real, Qt::CaseInsensitive ) ||
       
  1064          mFileDetails->mMimeType.contains( rn, Qt::CaseInsensitive ) )
       
  1065     {
       
  1066         realFormat = true;
       
  1067     }
       
  1068 
       
  1069     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::realFormatForLocal() [%d]"), realFormat);
       
  1070 
       
  1071     return realFormat;
       
  1072 }
       
  1073 
       
  1074 // -------------------------------------------------------------------------------------------------
       
  1075 //   QMPXVideoPlaybackControlsController::setDownloadSize()
       
  1076 // -------------------------------------------------------------------------------------------------
       
  1077 //
       
  1078 void QMPXVideoPlaybackControlsController::setDownloadSize( int size )
       
  1079 {
       
  1080     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::setDownloadSize() [%d]"), size);
       
  1081 
       
  1082     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1083     {
       
  1084         if ( mControls[i]->setDownloadSize( size ) )
       
  1085         {
       
  1086             break;
       
  1087         }
       
  1088     }
       
  1089 }
       
  1090 
       
  1091 // -------------------------------------------------------------------------------------------------
       
  1092 //   QMPXVideoPlaybackControlsController::updateDownloadPosition()
       
  1093 // -------------------------------------------------------------------------------------------------
       
  1094 //
       
  1095 void QMPXVideoPlaybackControlsController::updateDownloadPosition( int size )
       
  1096 {
       
  1097     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateDownloadPosition() [%d]"), size);
       
  1098 
       
  1099     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1100     {
       
  1101         if ( mControls[i]->updateDownloadPosition( size ) )
       
  1102         {
       
  1103             break;
       
  1104         }
       
  1105     }
       
  1106 }
       
  1107 
       
  1108 // -------------------------------------------------------------------------------------------------
       
  1109 // QMPXVideoPlaybackControlsController::handleErrors
       
  1110 // -------------------------------------------------------------------------------------------------
       
  1111 //
       
  1112 void QMPXVideoPlaybackControlsController::handleErrors()
       
  1113 {
       
  1114     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleErrors()"),
       
  1115                    _L("mState = %d"), mState );
       
  1116 }
       
  1117 
       
  1118 // -------------------------------------------------------------------------------------------------
       
  1119 //   QMPXVideoPlaybackControlsController::isSoftKeyVisible()
       
  1120 // -------------------------------------------------------------------------------------------------
       
  1121 //
       
  1122 bool QMPXVideoPlaybackControlsController::isSoftKeyVisible()
       
  1123 {
       
  1124     bool visible = false;
       
  1125 
       
  1126     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1127     {
       
  1128         if ( mControls[i]->controlIndex() == EMPXStatusPane )
       
  1129         {
       
  1130             if ( mControls[i]->isVisible() )
       
  1131             {
       
  1132                 visible = true;
       
  1133             }
       
  1134 
       
  1135             break;
       
  1136         }
       
  1137     }
       
  1138 
       
  1139     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isSoftKeyVisible() [%d]"), visible);
       
  1140 
       
  1141     return visible;
       
  1142 }
       
  1143 
       
  1144 // -------------------------------------------------------------------------------------------------
       
  1145 //   QMPXVideoPlaybackControlsController::handleTvOutEvent
       
  1146 // -------------------------------------------------------------------------------------------------
       
  1147 //
       
  1148 void QMPXVideoPlaybackControlsController::handleTvOutEvent(
       
  1149         bool connected, TMPXVideoPlaybackControlCommandIds event )
       
  1150 {
       
  1151     Q_UNUSED( event );
       
  1152 
       
  1153     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::handleTvOutEvent()"));
       
  1154 
       
  1155     mFileDetails->mTvOutConnected = connected;
       
  1156 
       
  1157     setDefaultBitmap();
       
  1158 
       
  1159     if ( mFileDetails->mTvOutConnected )
       
  1160     {
       
  1161         generateThumbNail();
       
  1162     }
       
  1163 
       
  1164     //
       
  1165     // Change the view.
       
  1166     // If Tv-out is connected, go to AudioOnlyView.
       
  1167     // If not, go back to default view.
       
  1168     //
       
  1169     TPlaybackViewMode viewMode = EFullScreenView;
       
  1170 
       
  1171     if ( mFileDetails->mTvOutConnected || ! mFileDetails->mVideoEnabled )
       
  1172     {
       
  1173         viewMode = EAudioOnlyView;
       
  1174     }
       
  1175 
       
  1176     changeViewMode( viewMode, false );
       
  1177 }
       
  1178 
       
  1179 // -------------------------------------------------------------------------------------------------
       
  1180 //   QMPXVideoPlaybackControlsController::changeViewMode
       
  1181 // -------------------------------------------------------------------------------------------------
       
  1182 //
       
  1183 void QMPXVideoPlaybackControlsController::changeViewMode(
       
  1184         TPlaybackViewMode viewMode, bool transitionEffect )
       
  1185 {
       
  1186     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::changeViewMode( %d, %d )"),
       
  1187             viewMode, transitionEffect );
       
  1188 
       
  1189     if ( viewMode != mViewMode )
       
  1190     {
       
  1191         switch ( viewMode )
       
  1192         {
       
  1193             case EFullScreenView:
       
  1194             case EDetailsView:
       
  1195             {
       
  1196                 if ( mFileDetails->mVideoEnabled && ! mFileDetails->mTvOutConnected )
       
  1197                 {
       
  1198                     mViewMode = viewMode;
       
  1199 
       
  1200                     //
       
  1201                     // Hack to clean up the screen before transition. We may not need it in NGA env
       
  1202                     //
       
  1203                     hideAllControls();
       
  1204 
       
  1205                     updateVideoRect( transitionEffect );
       
  1206                 }
       
  1207 
       
  1208                 break;
       
  1209             }
       
  1210             case EAudioOnlyView:
       
  1211             {
       
  1212                 if ( ! mFileDetails->mVideoEnabled || mFileDetails->mTvOutConnected )
       
  1213                 {
       
  1214                     mViewMode = viewMode;
       
  1215 
       
  1216                     mControlsConfig->updateControlList( EMPXControlCmdAudionOnlyViewOpened );
       
  1217                 }
       
  1218 
       
  1219                 break;
       
  1220             }
       
  1221             default:
       
  1222             {
       
  1223                 break;
       
  1224             }
       
  1225         }
       
  1226     }
       
  1227 }
       
  1228 
       
  1229 // -------------------------------------------------------------------------------------------------
       
  1230 //   QMPXVideoPlaybackControlsController::updateVideoRectDone
       
  1231 // -------------------------------------------------------------------------------------------------
       
  1232 //
       
  1233 void QMPXVideoPlaybackControlsController::updateVideoRectDone()
       
  1234 {
       
  1235     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRectDone()"));
       
  1236 
       
  1237     mViewTransitionIsGoingOn = false;
       
  1238 
       
  1239     TMPXVideoPlaybackControlCommandIds event = EMPXControlCmdFullScreenViewOpened;
       
  1240 
       
  1241     if ( mViewMode == EDetailsView )
       
  1242     {
       
  1243         event = EMPXControlCmdDetailsViewOpened;
       
  1244     }
       
  1245 
       
  1246     mControlsConfig->updateControlList( event );
       
  1247 }
       
  1248 
       
  1249 // -------------------------------------------------------------------------------------------------
       
  1250 //   QMPXVideoPlaybackControlsController::skipToPreviousVideoItem
       
  1251 // -------------------------------------------------------------------------------------------------
       
  1252 //
       
  1253 void QMPXVideoPlaybackControlsController::skipToPreviousVideoItem()
       
  1254 {
       
  1255     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::skipToPreviousVideoItem()"));
       
  1256 
       
  1257     if ( mViewMode == EFullScreenView )
       
  1258     {
       
  1259         handleCommand( EMPXPbvCmdPreviousListItem );
       
  1260     }
       
  1261 }
       
  1262 
       
  1263 // -------------------------------------------------------------------------------------------------
       
  1264 //   QMPXVideoPlaybackControlsController::skipToNextVideoItem
       
  1265 // -------------------------------------------------------------------------------------------------
       
  1266 //
       
  1267 void QMPXVideoPlaybackControlsController::skipToNextVideoItem()
       
  1268 {
       
  1269     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::skipToNextVideoItem()"));
       
  1270 
       
  1271     if ( mViewMode == EFullScreenView )
       
  1272     {
       
  1273         handleCommand( EMPXPbvCmdNextListItem );
       
  1274     }
       
  1275 }
       
  1276 
       
  1277 // -------------------------------------------------------------------------------------------------
       
  1278 //   QMPXVideoPlaybackControlsController::updateVideoRect()
       
  1279 // -------------------------------------------------------------------------------------------------
       
  1280 //
       
  1281 void QMPXVideoPlaybackControlsController::updateVideoRect( bool transitionEffect )
       
  1282 {
       
  1283     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRect( %d )"),
       
  1284             transitionEffect );
       
  1285 
       
  1286     if ( mFileDetails->mVideoEnabled && ! mFileDetails->mTvOutConnected )
       
  1287     {
       
  1288         mViewTransitionIsGoingOn = true;
       
  1289 
       
  1290         QRectF rect;
       
  1291 
       
  1292         MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRect() : mViewMode = %d )"),
       
  1293                 mViewMode );
       
  1294 
       
  1295         if ( mViewMode == EDetailsView )
       
  1296         {
       
  1297             QGraphicsWidget *parent = mLoader->findWidget( QString( "detailsPlaybackWindow" ) );
       
  1298             QGraphicsWidget *child = mLoader->findWidget( QString( "small_transparentWindow" ) );
       
  1299 
       
  1300             rect = parent->mapRectToScene( child->geometry() );
       
  1301         }
       
  1302         else if ( mViewMode == EFullScreenView )
       
  1303         {
       
  1304             QGraphicsWidget *widget = mLoader->findWidget( QString( "content" ) );
       
  1305             rect = widget->geometry();
       
  1306         }
       
  1307 
       
  1308         mViewWrapper->UpdateVideoRect(
       
  1309                 rect.x(), rect.y(), rect.width(), rect.height(), transitionEffect );
       
  1310     }
       
  1311 }
       
  1312 
       
  1313 // -------------------------------------------------------------------------------------------------
       
  1314 //   QMPXVideoPlaybackControlsController::setDefaultBitmap()
       
  1315 // -------------------------------------------------------------------------------------------------
       
  1316 //
       
  1317 void QMPXVideoPlaybackControlsController::setDefaultBitmap()
       
  1318 {
       
  1319     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::setDefaultBitmap()"));
       
  1320 
       
  1321     //
       
  1322     // set specific bitmaps for audio only and tv out cases
       
  1323     // If we already requested a thumbnail, we will set the thumbnail after we receive the thumbnail
       
  1324     //
       
  1325     if ( mLoader && mThumbNailState != EThumbNailRequsted )
       
  1326     {
       
  1327         QGraphicsWidget *tvOutBitmap = mLoader->findWidget( "tvOutBitmap" );
       
  1328         tvOutBitmap->setVisible( false );
       
  1329 
       
  1330         QGraphicsWidget *realAudioOnlyBitmap = mLoader->findWidget( "realAudioOnlyBitmap" );
       
  1331         realAudioOnlyBitmap->setVisible( false );
       
  1332 
       
  1333         QGraphicsWidget *partialAudioOnlyBitmap = mLoader->findWidget( "partialAudioOnlyBitmap" );
       
  1334         partialAudioOnlyBitmap->setVisible( false );
       
  1335 
       
  1336         QGraphicsWidget *audioOnlyBitmap = mLoader->findWidget( "audioOnlyBitmap" );
       
  1337         audioOnlyBitmap->setVisible( false );
       
  1338 
       
  1339         if ( mFileDetails->mTvOutConnected )
       
  1340         {
       
  1341             tvOutBitmap->setVisible( true );
       
  1342         }
       
  1343         else if ( mFileDetails->mRNFormat )
       
  1344         {
       
  1345             realAudioOnlyBitmap->setVisible( true );
       
  1346         }
       
  1347         else if ( mFileDetails->mPartialPlayback )
       
  1348         {
       
  1349             partialAudioOnlyBitmap->setVisible( true );
       
  1350         }
       
  1351         else
       
  1352         {
       
  1353             audioOnlyBitmap->setVisible( true );
       
  1354         }
       
  1355     }
       
  1356 }
       
  1357 
       
  1358 // -------------------------------------------------------------------------------------------------
       
  1359 //   QMPXVideoPlaybackControlsController::generateThumbNail()
       
  1360 // -------------------------------------------------------------------------------------------------
       
  1361 //
       
  1362 void QMPXVideoPlaybackControlsController::generateThumbNail()
       
  1363 {
       
  1364     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::generateThumbNail()"));
       
  1365 
       
  1366     //
       
  1367     // Generate thumbnail if it is local playback
       
  1368     //
       
  1369     if ( mFileDetails->mPlaybackMode == EMPXVideoLocal )
       
  1370     {
       
  1371         if ( mThumbNailState == EThumbNailEmpty )
       
  1372         {
       
  1373             mThumbnailManager = new ThumbnailManager(); ;
       
  1374 
       
  1375             mThumbnailManager->setThumbnailSize( ThumbnailManager::ThumbnailLarge );
       
  1376             mThumbnailManager->setQualityPreference( ThumbnailManager::OptimizeForPerformance );
       
  1377 
       
  1378             if ( connect( mThumbnailManager, SIGNAL( thumbnailReady( QPixmap , void * , int , int ) ),
       
  1379                           this, SLOT( handleThumbnailReady( QPixmap , void * , int , int ) ) ) )
       
  1380             {
       
  1381                 mThumbnailManager->getThumbnail( mFileDetails->mClipName );
       
  1382                 mThumbNailState = EThumbNailRequsted;
       
  1383             }
       
  1384         }
       
  1385     }
       
  1386     else
       
  1387     {
       
  1388         mThumbNailState = EThumbNailNotAvailable;
       
  1389     }
       
  1390 }
       
  1391 
       
  1392 // -------------------------------------------------------------------------------------------------
       
  1393 // QMPXVideoPlaybackControlsController::handleThumbnailReady()
       
  1394 // -------------------------------------------------------------------------------------------------
       
  1395 //
       
  1396 void QMPXVideoPlaybackControlsController::handleThumbnailReady(
       
  1397         QPixmap tnData, void *internal , int id, int error )
       
  1398 {
       
  1399     Q_UNUSED( internal );
       
  1400     Q_UNUSED( id );
       
  1401 
       
  1402     if( ! error && mLoader )
       
  1403     {
       
  1404         QGraphicsWidget *tvOutBitmap = mLoader->findWidget( "tvOutBitmap" );
       
  1405         HbLabel *tvOutLabel = qobject_cast<HbLabel*>( tvOutBitmap );
       
  1406 
       
  1407         QIcon *qicon = new QIcon( tnData );
       
  1408 
       
  1409         HbIcon *hbIcon = new HbIcon( *qicon );
       
  1410         hbIcon->setSize( tvOutBitmap->size() );
       
  1411         tvOutLabel->setIcon( *hbIcon );
       
  1412 
       
  1413         mThumbNailState = EThumbNailSet;
       
  1414     }
       
  1415     else
       
  1416     {
       
  1417         mThumbNailState = EThumbNailNotAvailable;
       
  1418     }
       
  1419 
       
  1420     setDefaultBitmap();
       
  1421 
       
  1422     disconnect( mThumbnailManager, SIGNAL( thumbnailReady( QPixmap , void * , int , int ) ),
       
  1423                 this, SLOT( handleThumbnailReady( QPixmap , void * , int , int ) ) );
       
  1424 }
       
  1425 
       
  1426 // -------------------------------------------------------------------------------------------------
       
  1427 // QMPXVideoPlaybackControlsController::attachVideo()
       
  1428 // -------------------------------------------------------------------------------------------------
       
  1429 //
       
  1430 void QMPXVideoPlaybackControlsController::attachVideo()
       
  1431 {
       
  1432     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::attachVideo()"),
       
  1433                    _L("file = %s"), mFileDetails->mClipName.data() );
       
  1434 
       
  1435     //
       
  1436     // close playback view
       
  1437     //
       
  1438     mView->closePlaybackView();
       
  1439 
       
  1440     //
       
  1441     // emit signal to launch videoservices itemSelected() slot
       
  1442     //
       
  1443     emit( attachVideoPath( mFileDetails->mClipName ) );
       
  1444 
       
  1445 }
       
  1446 
       
  1447 // -------------------------------------------------------------------------------------------------
       
  1448 // QMPXVideoPlaybackControlsController::sendVideo()
       
  1449 // -------------------------------------------------------------------------------------------------
       
  1450 //
       
  1451 void QMPXVideoPlaybackControlsController::sendVideo()
       
  1452 {
       
  1453     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::sendVideo()"),
       
  1454                    _L("file = %s"), mFileDetails->mClipName.data() );
       
  1455 
       
  1456     //
       
  1457     // pause playback
       
  1458     //
       
  1459     handleCommand( EMPXPbvCmdPause );
       
  1460 
       
  1461     //
       
  1462     // send video to shareUI
       
  1463     //
       
  1464     ShareUi dlg;
       
  1465     QStringList fileList;
       
  1466     fileList.append( mFileDetails->mClipName );
       
  1467     dlg.send( fileList, true );
       
  1468 }
       
  1469 
       
  1470 // -------------------------------------------------------------------------------------------------
       
  1471 // QMPXVideoPlaybackControlsController::handleRNLogoVisibleChanged()
       
  1472 // -------------------------------------------------------------------------------------------------
       
  1473 //
       
  1474 void QMPXVideoPlaybackControlsController::handleRNLogoVisibleChanged()
       
  1475 {
       
  1476     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleRNLogoVisibleChanged()"));
       
  1477 
       
  1478     QGraphicsWidget *widget = mLoader->findWidget( QString( "rnLogoBitmap" ) );
       
  1479 
       
  1480     if ( widget->isVisible() )
       
  1481     {
       
  1482         if ( mRNLogoTimer )
       
  1483         {
       
  1484             delete mRNLogoTimer;
       
  1485             mRNLogoTimer = NULL;
       
  1486         }
       
  1487 
       
  1488         mRNLogoTimer = new QTimer( this );
       
  1489         mRNLogoTimer->setInterval( KMPXRNLogoTimeOut );
       
  1490         mRNLogoTimer->setSingleShot( true );
       
  1491         connect( mRNLogoTimer, SIGNAL( timeout() ), this, SLOT( handleRNLogoTimeout() ) );
       
  1492 
       
  1493         mRNLogoTimer->start();
       
  1494     }
       
  1495 }
       
  1496 
       
  1497 // -------------------------------------------------------------------------------------------------
       
  1498 // QMPXVideoPlaybackControlsController::handleRNLogoTimeout()
       
  1499 // -------------------------------------------------------------------------------------------------
       
  1500 //
       
  1501 void QMPXVideoPlaybackControlsController::handleRNLogoTimeout()
       
  1502 {
       
  1503     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::handleRNLogoTimeout()"));
       
  1504 
       
  1505     if ( mRNLogoTimer->isActive() )
       
  1506     {
       
  1507         mRNLogoTimer->stop();
       
  1508     }
       
  1509 
       
  1510     //
       
  1511     // Remove RN logo from the controls list and issue play command if needed
       
  1512     //
       
  1513     mControlsConfig->updateControlList( EMPXControlCmdRemoveRNLogo );
       
  1514     handleCommand( EMPXPbvCmdRealOneBitmapTimeout );
       
  1515 }
       
  1516 
       
  1517 // -------------------------------------------------------------------------------------------------
       
  1518 // QMPXVideoPlaybackControlsController::isRNLogoBitmapInControlList()
       
  1519 // -------------------------------------------------------------------------------------------------
       
  1520 //
       
  1521 bool QMPXVideoPlaybackControlsController::isRNLogoBitmapInControlList()
       
  1522 {
       
  1523     bool exist = false;
       
  1524 
       
  1525     //
       
  1526     // If we have a rn logo in the list, we are supposed to show the logo all the time
       
  1527     // unless we are in the middle of orientation transition
       
  1528     //
       
  1529     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1530     {
       
  1531         if ( mControls[i]->controlIndex() == EMPXRealLogoBitmap )
       
  1532         {
       
  1533             exist = true;
       
  1534             break;
       
  1535         }
       
  1536     }
       
  1537 
       
  1538     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isRNLogoBitmapInControlList() [%d]"), exist);
       
  1539 
       
  1540     return exist;
       
  1541 }
       
  1542 
       
  1543 // -------------------------------------------------------------------------------------------------
       
  1544 // QMPXVideoPlaybackControlsController::handleOrientationChanged()
       
  1545 // -------------------------------------------------------------------------------------------------
       
  1546 //
       
  1547 void QMPXVideoPlaybackControlsController::handleOrientationChanged( Qt::Orientation orientation )
       
  1548 {
       
  1549     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::handleOrientationChanged()"),
       
  1550                    _L("old orientation %d, new orientation = %d"), mOrientation, orientation );
       
  1551 
       
  1552     Qt::Orientation  oldOrientaiton = mOrientation;
       
  1553     mOrientation = orientation;
       
  1554 
       
  1555     if ( oldOrientaiton == Qt::Vertical && orientation == Qt::Horizontal )
       
  1556     {
       
  1557         showControls();
       
  1558     }
       
  1559 }
       
  1560 
       
  1561 // End of File