videoplayback/videoplaybackview/controlsrc/videoplaybackcontrolscontroller.cpp
changeset 44 518105d52e45
child 49 824471cb468a
equal deleted inserted replaced
42:17f382c040b1 44:518105d52e45
       
     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 VideoPlaybackControlsController
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: da1mmcf#46 %
       
    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 "videobaseplaybackview.h"
       
    43 #include "videoplaybackcontrolbar.h"
       
    44 #include "videoplaybackcontrolpolicy.h"
       
    45 #include "videoplaybackdocumentloader.h"
       
    46 #include "videoplaybackviewfiledetails.h"
       
    47 #include "videoplaybackstatuspanecontrol.h"
       
    48 #include "videoplaybackfiledetailswidget.h"
       
    49 #include "videoplaybackfullscreencontrol.h"
       
    50 #include "videoplaybackcontrolscontroller.h"
       
    51 #include "videoplaybackcontrolconfiguration.h"
       
    52 #include "videoplaybackdetailsplaybackwindow.h"
       
    53 #include "videoservices.h"
       
    54 
       
    55 
       
    56 // ================= MEMBER FUNCTIONS ==============================================================
       
    57 
       
    58 // -------------------------------------------------------------------------------------------------
       
    59 // VideoPlaybackControlsController::VideoPlaybackControlsController()
       
    60 // -------------------------------------------------------------------------------------------------
       
    61 //
       
    62 VideoPlaybackControlsController::VideoPlaybackControlsController(
       
    63         VideoBasePlaybackView *view,
       
    64         CMPXVideoViewWrapper *viewWrapper,
       
    65         VideoPlaybackViewFileDetails *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("VideoPlaybackControlsController::VideoPlaybackControlsController()"));
       
    84 
       
    85     initializeController();
       
    86 }
       
    87 
       
    88 // -------------------------------------------------------------------------------------------------
       
    89 // VideoPlaybackControlsController::initializeController()
       
    90 // -------------------------------------------------------------------------------------------------
       
    91 //
       
    92 void VideoPlaybackControlsController::initializeController()
       
    93 {
       
    94     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::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("VideoPlaybackControlsController::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 VideoPlaybackDocumentLoader( this );
       
   113     mLoader->load( KPLAYBACKVIEW_DOCML, &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("VideoPlaybackControlsController::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( KControlsTimeOut );
       
   139     mControlsTimer->setSingleShot( false );
       
   140     connect( mControlsTimer, SIGNAL( timeout() ), this, SLOT( hideAllControls() ) );
       
   141 
       
   142     mControlsPolicy = new VideoPlaybackControlPolicy();
       
   143 
       
   144     mControlsConfig = new VideoPlaybackControlConfiguration( 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( KControlsTimeOut );
       
   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     // if videoplayback is in service mode, create a videoservices instance
       
   165     //
       
   166     if ( XQServiceUtil::isService() && ! mVideoServices )
       
   167     {
       
   168         //
       
   169         // obtain VideoServices instance
       
   170         //
       
   171         mVideoServices = VideoServices::instance();
       
   172 
       
   173         //
       
   174         // allow 'attach' operation only for non-streaming media clips
       
   175         //
       
   176         if ( mVideoServices && mFileDetails->mPlaybackMode == EMPXVideoLocal )
       
   177         {
       
   178             //
       
   179             // determine if this is 'attach' operation
       
   180             //
       
   181             mIsAttachOperation = ( mVideoServices->currentService() == VideoServices::EUriFetcher );
       
   182 
       
   183             if ( mIsAttachOperation )
       
   184             {
       
   185                 //
       
   186                 // connect signal filePath() to videoservices slot itemSelected()
       
   187                 //
       
   188                 connect( this, SIGNAL( attachVideoPath( const QString& ) ),
       
   189                          mVideoServices, SLOT( itemSelected( const QString& ) ) );
       
   190             }
       
   191         }
       
   192     }
       
   193 }
       
   194 
       
   195 // -------------------------------------------------------------------------------------------------
       
   196 // VideoPlaybackControlsController::~VideoPlaybackControlsController
       
   197 // -------------------------------------------------------------------------------------------------
       
   198 //
       
   199 VideoPlaybackControlsController::~VideoPlaybackControlsController()
       
   200 {
       
   201     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::~VideoPlaybackControlsController()"));
       
   202 
       
   203     mView->ungrabGesture( Qt::TapGesture );
       
   204     disconnect( mView, SIGNAL( tappedOnScreen() ), this, SLOT( handleTappedOnScreen() ) );
       
   205 
       
   206     if ( mFileDetails->mMultiItemPlaylist && mFileDetails->mSeekable )
       
   207     {
       
   208         mView->ungrabGesture( Qt::PanGesture );
       
   209 
       
   210         disconnect( mView, SIGNAL( pannedToRight() ), this, SLOT( skipToNextVideoItem() ) );
       
   211         disconnect( mView, SIGNAL( pannedToLeft() ), this, SLOT( skipToPreviousVideoItem() ) );
       
   212     }
       
   213 
       
   214     disconnect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
       
   215     disconnect( mControlsTimer, SIGNAL( timeout() ), this, SLOT( hideAllControls() ) );
       
   216     disconnect( hbInstance->allMainWindows()[0], SIGNAL( orientationChanged( Qt::Orientation ) ),
       
   217                 this, SLOT( handleOrientationChanged( Qt::Orientation ) ) );
       
   218 
       
   219     mView->setWidget( NULL );
       
   220 
       
   221     mControls.clear();
       
   222 
       
   223     if ( mControlsTimer )
       
   224     {
       
   225         delete mControlsTimer;
       
   226         mControlsTimer = NULL;
       
   227     }
       
   228 
       
   229     if ( mRNLogoTimer )
       
   230     {
       
   231         disconnect( mRNLogoTimer, SIGNAL( timeout() ), this, SLOT( handleRNLogoTimeout() ) );
       
   232 
       
   233         delete mRNLogoTimer;
       
   234         mRNLogoTimer = NULL;
       
   235     }
       
   236 
       
   237     if ( mControlsPolicy )
       
   238     {
       
   239         delete mControlsPolicy;
       
   240         mControlsPolicy = NULL;
       
   241     }
       
   242 
       
   243     if ( mControlsConfig )
       
   244     {
       
   245         delete mControlsConfig;
       
   246         mControlsConfig = NULL;
       
   247     }
       
   248 
       
   249     if ( mLoader )
       
   250     {
       
   251         delete mLoader;
       
   252         mLoader = NULL;
       
   253     }
       
   254 
       
   255     if ( mThumbnailManager )
       
   256     {
       
   257         delete mThumbnailManager;
       
   258         mThumbnailManager = NULL;
       
   259     }
       
   260 
       
   261     if ( mVolumeControl )
       
   262     {
       
   263         delete mVolumeControl;
       
   264         mVolumeControl = NULL;
       
   265     }
       
   266 
       
   267     if ( mIsAttachOperation )
       
   268     {
       
   269         //
       
   270         // disable connection for 'attach' operation
       
   271         //
       
   272         disconnect( this, SIGNAL( attachVideoPath( const QString& ) ),
       
   273                     mVideoServices, SLOT( itemSelected( const QString& ) ) );
       
   274     }
       
   275 
       
   276     if ( mVideoServices )
       
   277     {
       
   278         //
       
   279         // decrease videoservices instance count
       
   280         //
       
   281     	mVideoServices->decreaseReferenceCount();
       
   282     	mVideoServices = 0;
       
   283     }
       
   284 }
       
   285 
       
   286 // -------------------------------------------------------------------------------------------------
       
   287 // VideoPlaybackControlsController::addFileDetails()
       
   288 // -------------------------------------------------------------------------------------------------
       
   289 //
       
   290 void VideoPlaybackControlsController::addFileDetails(
       
   291     VideoPlaybackViewFileDetails* details )
       
   292 {
       
   293     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::addFileDetails"));
       
   294 
       
   295     mFileDetails = details;
       
   296 
       
   297     mFileDetails->mRNFormat = realFormat( mFileDetails->mClipName );
       
   298 
       
   299     mControlsConfig->updateControlsWithFileDetails();
       
   300 
       
   301     //
       
   302     // for audio-only clips and tv-out, default view is flip view
       
   303     //
       
   304     if ( ! details->mVideoEnabled )
       
   305     {
       
   306         changeViewMode( EAudioOnlyView, false );
       
   307     }
       
   308 
       
   309     if ( details->mTvOutConnected )
       
   310     {
       
   311         handleEvent( EControlCmdTvOutConnected );
       
   312     }
       
   313 
       
   314     //
       
   315     // Dimmed the volume control if it is video only
       
   316     //
       
   317     if ( ! mFileDetails->mAudioEnabled )
       
   318     {
       
   319         mVolumeControl->setValue( 0 );
       
   320         mVolumeControl->setEnabled( false );
       
   321     }
       
   322 
       
   323     //
       
   324     // grab pan gesture for playlist and seekable(skippable) clip
       
   325     //
       
   326     if ( mFileDetails->mMultiItemPlaylist && mFileDetails->mSeekable )
       
   327     {
       
   328         mView->grabGesture( Qt::PanGesture );
       
   329         connect( mView, SIGNAL( pannedToRight() ), this, SLOT( skipToPreviousVideoItem() ) );
       
   330         connect( mView, SIGNAL( pannedToLeft() ), this, SLOT( skipToNextVideoItem() ) );
       
   331     }
       
   332 }
       
   333 
       
   334 // -------------------------------------------------------------------------------------------------
       
   335 // VideoPlaybackControlsController::handleEvent
       
   336 // -------------------------------------------------------------------------------------------------
       
   337 //
       
   338 void VideoPlaybackControlsController::handleEvent(
       
   339     TVideoPlaybackControlCommandIds event, int value )
       
   340 {
       
   341     MPX_DEBUG(_L("VideoPlaybackControlsController::handleEvent(%d)"), event);
       
   342 
       
   343     switch ( event )
       
   344     {
       
   345         case EControlCmdSetPosition:
       
   346         {
       
   347             MPX_DEBUG(_L("    [EControlCmdSetPosition [%d]]"), value );
       
   348 
       
   349             positionChanged( (qreal)value / (qreal)KPbMilliMultiplier);
       
   350             break;
       
   351         }
       
   352         case EControlCmdSetDuration:
       
   353         {
       
   354             MPX_DEBUG(_L("    [EControlCmdSetDuration [%d]]"), value );
       
   355 
       
   356             durationChanged( (qreal)value / (qreal)KPbMilliMultiplier );
       
   357             break;
       
   358         }
       
   359         case EControlCmdStateChanged:
       
   360         {
       
   361             MPX_DEBUG(_L("    [EControlCmdStateChanged]"));
       
   362 
       
   363             handleStateChange( (TMPXPlaybackState)value );
       
   364             break;
       
   365         }
       
   366         case EControlCmdSetVolume:
       
   367         {
       
   368             MPX_DEBUG(_L("    [EControlCmdSetVolume [%d]]"), value );
       
   369 
       
   370             volumeChanged( value );
       
   371             break;
       
   372         }
       
   373         case EControlCmdSetAspectRatio:
       
   374         {
       
   375             MPX_DEBUG(_L("    [EControlCmdSetAspectRatio %d]"), value );
       
   376 
       
   377             aspectRatioChanged( value );
       
   378 
       
   379             break;
       
   380         }
       
   381         case EControlCmdSetDownloadSize:
       
   382         {
       
   383             MPX_DEBUG(_L("    [EControlCmdSetDownloadSize [%d]]"), value );
       
   384             setDownloadSize( value );
       
   385             break;
       
   386         }
       
   387         case EControlCmdDownloadUpdated:
       
   388         {
       
   389             MPX_DEBUG(_L("    [EControlCmdDownloadUpdated [%d]]"), value );
       
   390             updateDownloadPosition( value );
       
   391             break;
       
   392         }
       
   393         case EControlCmdDownloadComplete:
       
   394         {
       
   395             MPX_DEBUG(_L("    [EControlCmdDownloadComplete [%d]]"), value);
       
   396             updateDownloadPosition( value );
       
   397             break;
       
   398         }
       
   399         case EControlCmdSetDownloadPaused:
       
   400         case EControlCmdClearDownloadPaused:
       
   401         {
       
   402             mControlsConfig->updateControlList( event );
       
   403             break;
       
   404         }
       
   405         case EControlCmdTvOutConnected:
       
   406         {
       
   407             MPX_DEBUG(_L("    [EControlCmdTvOutConnected]"));
       
   408 
       
   409             handleTvOutEvent( true, event );
       
   410             break;
       
   411         }
       
   412         case EControlCmdTvOutDisconnected:
       
   413         {
       
   414             MPX_DEBUG(_L("    [EControlCmdTvOutDisConnected]"));
       
   415 
       
   416             handleTvOutEvent( false, event );
       
   417             break;
       
   418         }
       
   419         case EControlCmdHandleErrors:
       
   420         {
       
   421             MPX_DEBUG(_L("    [EControlCmdHandleErrors]"));
       
   422 
       
   423             handleErrors();
       
   424 
       
   425             break;
       
   426         }
       
   427         case EControlCmdShowVolumeControls:
       
   428         {
       
   429             MPX_DEBUG(_L("    [EControlCmdShowVolumeControls]"));
       
   430 
       
   431             showVolumeControls();
       
   432             break;
       
   433         }
       
   434     }
       
   435 }
       
   436 
       
   437 // -------------------------------------------------------------------------------------------------
       
   438 // VideoPlaybackControlsController::handleStateChange
       
   439 // -------------------------------------------------------------------------------------------------
       
   440 //
       
   441 void VideoPlaybackControlsController::handleStateChange( TMPXPlaybackState newState )
       
   442 {
       
   443     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::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 // VideoPlaybackControlsController::controlsListUpdated()
       
   480 // -------------------------------------------------------------------------------------------------
       
   481 //
       
   482 void VideoPlaybackControlsController::controlsListUpdated()
       
   483 {
       
   484     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::controlsListUpdated()"));
       
   485 
       
   486     hideAllControls();
       
   487 
       
   488     QList<TVideoPlaybackControls>& updatedList = mControlsConfig->controlList();
       
   489 
       
   490     QList<TVideoPlaybackControls> 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 // VideoPlaybackControlsController::appendControl()
       
   546 // -------------------------------------------------------------------------------------------------
       
   547 //
       
   548 void VideoPlaybackControlsController::appendControl( TVideoPlaybackControls controlIndex )
       
   549 {
       
   550     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::appendControl()"),
       
   551                    _L("control index = %d"), controlIndex );
       
   552 
       
   553     TUint properties = 0;
       
   554 
       
   555     mControlsPolicy->setControlProperties( controlIndex, properties, mFileDetails, mViewMode );
       
   556     VideoPlaybackFullScreenControl* control;
       
   557 
       
   558     switch ( controlIndex )
       
   559     {
       
   560         case EBufferingAnimation:
       
   561         {
       
   562             //
       
   563             // Load animation icons
       
   564             //
       
   565             QString animationName = ":/videoplaybackview/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("    EBufferingAnimation 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 VideoPlaybackFullScreenControl( this,
       
   588                                                               controlIndex,
       
   589                                                               bufferingAnim,
       
   590                                                               properties );
       
   591             mControls.append( control );
       
   592 
       
   593             break;
       
   594         }
       
   595         case EStatusPane:
       
   596         {
       
   597             //
       
   598             // Status key (signal + title + back key)
       
   599             //
       
   600             control = new VideoPlaybackStatusPaneControl( this,
       
   601                                                               controlIndex,
       
   602                                                               NULL,
       
   603                                                               properties );
       
   604             mControls.append( control );
       
   605 
       
   606             break;
       
   607         }
       
   608         case EControlBar:
       
   609         {
       
   610             //
       
   611             // Button bar
       
   612             //
       
   613             QGraphicsWidget *widget = mLoader->findWidget( QString( "controlBarLayout" ) );
       
   614             VideoPlaybackControlBar *controlBar =
       
   615                 qobject_cast<VideoPlaybackControlBar*>( widget );
       
   616             controlBar->initialize();
       
   617 
       
   618             control = new VideoPlaybackFullScreenControl( this,
       
   619                                                               controlIndex,
       
   620                                                               controlBar,
       
   621                                                               properties );
       
   622             mControls.append( control );
       
   623 
       
   624             break;
       
   625         }
       
   626         case EFileDetailsWidget:
       
   627         {
       
   628             QGraphicsWidget *widget = mLoader->findWidget( QString( "fileDetailsLayout" ) );
       
   629             VideoPlaybackFileDetailsWidget *fileDetails =
       
   630                 qobject_cast<VideoPlaybackFileDetailsWidget*>( widget );
       
   631 
       
   632             control = new VideoPlaybackFullScreenControl( this,
       
   633                                                               controlIndex,
       
   634                                                               fileDetails,
       
   635                                                               properties );
       
   636 
       
   637             mControls.append( control );
       
   638             break;
       
   639         }
       
   640         case EIndicatorBitmap:
       
   641         {
       
   642             QGraphicsWidget *widget = mLoader->findWidget( QString( "bitmapLayout" ) );
       
   643             HbWidget *bitmapWidget = qobject_cast<HbWidget*>( widget );
       
   644 
       
   645             setDefaultBitmap();
       
   646             control = new VideoPlaybackFullScreenControl( this,
       
   647                                                               controlIndex,
       
   648                                                               bitmapWidget,
       
   649                                                               properties );
       
   650             mControls.append( control );
       
   651 
       
   652             break;
       
   653         }
       
   654         case ERealLogoBitmap:
       
   655         {
       
   656             QGraphicsWidget *widget = mLoader->findWidget( QString( "rnLogoBitmap" ) );
       
   657             HbWidget *bitmapWidget = qobject_cast<HbWidget*>( widget );
       
   658 
       
   659             control = new VideoPlaybackFullScreenControl( 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 EDetailsViewPlaybackWindow:
       
   671         {
       
   672             QGraphicsWidget *widget = mLoader->findWidget( QString( "detailsPlaybackWindow" ) );
       
   673             VideoPlaybackDetailsPlaybackWindow *detailsPlaybackWindow =
       
   674                     qobject_cast<VideoPlaybackDetailsPlaybackWindow*>( widget );
       
   675             detailsPlaybackWindow->initialize();
       
   676 
       
   677             control = new VideoPlaybackFullScreenControl( this,
       
   678                                                               controlIndex,
       
   679                                                               detailsPlaybackWindow,
       
   680                                                               properties );
       
   681             mControls.append( control );
       
   682 
       
   683             break;
       
   684         }
       
   685     }
       
   686 }
       
   687 
       
   688 // -------------------------------------------------------------------------------------------------
       
   689 // VideoPlaybackControlsController::handleTappedOnScreen()
       
   690 // -------------------------------------------------------------------------------------------------
       
   691 //
       
   692 void VideoPlaybackControlsController::handleTappedOnScreen()
       
   693 {
       
   694     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::handleTappedOnScreen()"));
       
   695 
       
   696     //
       
   697     // If we are in full screen view, toggle the visibility when playing and paused
       
   698     // If we are in details view, issue playpause
       
   699     // If we are in audio only view, ignore
       
   700     //
       
   701     switch( mViewMode )
       
   702     {
       
   703         case EFullScreenView:
       
   704         {
       
   705             if ( mState == EPbStatePlaying || mState == EPbStatePaused )
       
   706             {
       
   707                 if ( isVisible() )
       
   708                 {
       
   709                     //
       
   710                     // If the volume control is visible, hide it
       
   711                     //
       
   712                     if ( mVolumeControl->isVisible() )
       
   713                     {
       
   714                         mVolumeControl->setVisible( false );
       
   715                     }
       
   716 
       
   717                     hideAllControls();
       
   718                 }
       
   719                 else
       
   720                 {
       
   721                     showControls();
       
   722                 }
       
   723             }
       
   724 
       
   725             break;
       
   726         }
       
   727         case EDetailsView:
       
   728         {
       
   729             //
       
   730             // ignore the tap for 'Pause' action for non-pausable stream in 
       
   731             // 'Details' view during 'Playing' state
       
   732             //
       
   733             if ( mState != EPbStatePlaying || mFileDetails->mPausableStream )
       
   734             {
       
   735                 handleCommand( EMPXPbvCmdPlayPause );
       
   736             }
       
   737 
       
   738             break;
       
   739         }
       
   740     }
       
   741 }
       
   742 
       
   743 // -------------------------------------------------------------------------------------------------
       
   744 // VideoPlaybackControlsController::resetDisappearingTimers()
       
   745 // -------------------------------------------------------------------------------------------------
       
   746 //
       
   747 void VideoPlaybackControlsController::resetDisappearingTimers( TTimerAction timerAction )
       
   748 {
       
   749     MPX_DEBUG(_L("VideoPlaybackControlsController::resetDisappearingTimers()"));
       
   750 
       
   751     if ( mControlsTimer->isActive() )
       
   752     {
       
   753         mControlsTimer->stop();
       
   754     }
       
   755 
       
   756     //
       
   757     //  Do not start the time for DetailsView and AudioOnlyView
       
   758     //
       
   759     if ( timerAction == ETimerReset &&
       
   760          mState == EPbStatePlaying &&
       
   761          mViewMode == EFullScreenView )
       
   762     {
       
   763         MPX_DEBUG(_L("    Starting Controls Timer"));
       
   764 
       
   765         mControlsTimer->start();
       
   766     }
       
   767 }
       
   768 
       
   769 // -------------------------------------------------------------------------------------------------
       
   770 //   VideoPlaybackControlsController::hideAllControls()
       
   771 // -------------------------------------------------------------------------------------------------
       
   772 //
       
   773 void VideoPlaybackControlsController::hideAllControls()
       
   774 {
       
   775     MPX_DEBUG(_L("VideoPlaybackControlsController::hideControls()"));
       
   776 
       
   777     resetDisappearingTimers( ETimerCancel );
       
   778 
       
   779     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   780     {
       
   781         mControls[i]->setVisible( false );
       
   782     }
       
   783 }
       
   784 
       
   785 // -------------------------------------------------------------------------------------------------
       
   786 //   VideoPlaybackControlsController::showControls()
       
   787 // -------------------------------------------------------------------------------------------------
       
   788 //
       
   789 void VideoPlaybackControlsController::showControls()
       
   790 {
       
   791     MPX_DEBUG(_L("VideoPlaybackControlsController::showControls()"));
       
   792 
       
   793     resetDisappearingTimers( ETimerReset );
       
   794 
       
   795     if ( ! mViewTransitionIsGoingOn && mOrientation == Qt::Horizontal )
       
   796     {
       
   797         for ( int i = 0 ; i < mControls.count() ; i++ )
       
   798         {
       
   799             mControls[i]->setVisibility( mState );
       
   800         }
       
   801     }
       
   802 }
       
   803 
       
   804 // -------------------------------------------------------------------------------------------------
       
   805 //   VideoPlaybackControlsController::isVisible()
       
   806 // -------------------------------------------------------------------------------------------------
       
   807 //
       
   808 bool VideoPlaybackControlsController::isVisible()
       
   809 {
       
   810     bool visible = false;
       
   811 
       
   812     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   813     {
       
   814         if ( mControls[i]->controlIndex() == EControlBar )
       
   815         {
       
   816             if ( mControls[i]->isVisible() )
       
   817             {
       
   818                 visible = true;
       
   819             }
       
   820 
       
   821             break;
       
   822         }
       
   823     }
       
   824 
       
   825     MPX_DEBUG(_L("VideoPlaybackControlsController::isVisible() [%d]"), visible);
       
   826 
       
   827     return visible;
       
   828 }
       
   829 
       
   830 // -------------------------------------------------------------------------------------------------
       
   831 //   VideoPlaybackControlsController::handleCommand()
       
   832 // -------------------------------------------------------------------------------------------------
       
   833 //
       
   834 void VideoPlaybackControlsController::handleCommand(
       
   835         TMPXVideoPlaybackViewCommandIds command, int value )
       
   836 {
       
   837     MPX_DEBUG(_L("VideoPlaybackControlsController::handleCommand(%d)"), command);
       
   838 
       
   839     switch( command )
       
   840     {
       
   841         case EMPXPbvCmdSetPosition:
       
   842         {
       
   843             TRAP_IGNORE( mViewWrapper->SetPropertyL( EPbPropertyPosition,
       
   844                                                      value * KPbMilliMultiplier ) );
       
   845             break;
       
   846         }
       
   847         case EMPXPbvCmdSetVolume:
       
   848         {
       
   849             TRAP_IGNORE( mViewWrapper->SetPropertyL( EPbPropertyVolume, value ) );
       
   850             break;
       
   851         }
       
   852         default:
       
   853         {
       
   854             TRAP_IGNORE( mViewWrapper->HandleCommandL( command ) );
       
   855             break;
       
   856         }
       
   857     }
       
   858 }
       
   859 
       
   860 // -------------------------------------------------------------------------------------------------
       
   861 //   VideoPlaybackControlsController::volumeChanged()
       
   862 // -------------------------------------------------------------------------------------------------
       
   863 //
       
   864 void VideoPlaybackControlsController::volumeChanged( int volume )
       
   865 {
       
   866     MPX_DEBUG(_L("VideoPlaybackControlsController::volumeChanged() [%d]"), volume);
       
   867 
       
   868     if ( mVolumeControl )
       
   869     {
       
   870         mVolumeControl->setValue( volume );
       
   871     }
       
   872 }
       
   873 
       
   874 // -------------------------------------------------------------------------------------------------
       
   875 //   VideoPlaybackControlsController::showVolumeControls()
       
   876 // -------------------------------------------------------------------------------------------------
       
   877 //
       
   878 void VideoPlaybackControlsController::showVolumeControls()
       
   879 {
       
   880     MPX_DEBUG(_L("VideoPlaybackControlsController::showVolumeControls()"));
       
   881 
       
   882     if ( mVolumeControl )
       
   883     {
       
   884         mVolumeControl->setVisible( true );
       
   885     }
       
   886 }
       
   887 
       
   888 // -------------------------------------------------------------------------------------------------
       
   889 //   VideoPlaybackControlsController::durationChanged()
       
   890 // -------------------------------------------------------------------------------------------------
       
   891 //
       
   892 void VideoPlaybackControlsController::durationChanged( int duration )
       
   893 {
       
   894     MPX_DEBUG(_L("VideoPlaybackControlsController::durationChanged() [%d]"), duration);
       
   895 
       
   896     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   897     {
       
   898         if ( mControls[i]->durationChanged( duration ) )
       
   899         {
       
   900             break;
       
   901         }
       
   902     }
       
   903 }
       
   904 
       
   905 // -------------------------------------------------------------------------------------------------
       
   906 //   VideoPlaybackControlsController::positionChanged()
       
   907 // -------------------------------------------------------------------------------------------------
       
   908 //
       
   909 void VideoPlaybackControlsController::positionChanged( int position )
       
   910 {
       
   911     MPX_DEBUG(_L("VideoPlaybackControlsController::positionChanged() [%d]"), position);
       
   912 
       
   913     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   914     {
       
   915         if ( mControls[i]->positionChanged( position ) )
       
   916         {
       
   917             break;
       
   918         }
       
   919     }
       
   920 }
       
   921 
       
   922 // -------------------------------------------------------------------------------------------------
       
   923 //   VideoPlaybackControlsController::aspectRatioChanged()
       
   924 // -------------------------------------------------------------------------------------------------
       
   925 //
       
   926 void VideoPlaybackControlsController::aspectRatioChanged( int aspectRatio )
       
   927 {
       
   928     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::aspectRatioChanged() [%d]"), aspectRatio);
       
   929 
       
   930     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   931     {
       
   932         if ( mControls[i]->aspectRatioChanged( aspectRatio ) )
       
   933         {
       
   934             break;
       
   935         }
       
   936     }
       
   937 }
       
   938 
       
   939 // -------------------------------------------------------------------------------------------------
       
   940 //   VideoPlaybackControlsController::updateState()
       
   941 // -------------------------------------------------------------------------------------------------
       
   942 //
       
   943 void VideoPlaybackControlsController::updateState()
       
   944 {
       
   945     MPX_DEBUG(_L("VideoPlaybackControlsController::updateState() [%d]"), mState);
       
   946 
       
   947     for ( int i = 0 ; i < mControls.count() ; i++ )
       
   948     {
       
   949         mControls[i]->updateState( mState );
       
   950     }
       
   951 }
       
   952 
       
   953 // -------------------------------------------------------------------------------------------------
       
   954 // VideoPlaybackControlsController::realFormat()
       
   955 // -------------------------------------------------------------------------------------------------
       
   956 //
       
   957 bool VideoPlaybackControlsController::realFormat( QString filename )
       
   958 {
       
   959     bool realFormat = false;
       
   960 
       
   961     if ( !filename.isNull() && !filename.isEmpty() )
       
   962     {
       
   963         if ( mFileDetails->mPlaybackMode == EMPXVideoStreaming ||
       
   964              mFileDetails->mPlaybackMode == EMPXVideoLiveStreaming )
       
   965         {
       
   966             TBufC<255> file(filename.utf16());
       
   967             realFormat = realFormatForStreaming( file );
       
   968         }
       
   969         else
       
   970         {
       
   971             realFormat = realFormatForLocal();
       
   972         }
       
   973     }
       
   974 
       
   975     MPX_DEBUG(_L("VideoPlaybackControlsController::realFormat() [%d]"), realFormat);
       
   976 
       
   977     return realFormat;
       
   978 }
       
   979 
       
   980 // -------------------------------------------------------------------------------------------------
       
   981 // VideoPlaybackControlsController::realFormatForStreaming()
       
   982 // -------------------------------------------------------------------------------------------------
       
   983 //
       
   984 bool VideoPlaybackControlsController::realFormatForStreaming( const TDesC& des )
       
   985 {
       
   986     bool realFormat = false;
       
   987     TParse filePath;
       
   988 
       
   989     _LIT(KMPXRMEXT, ".R" );
       
   990 
       
   991     int err = filePath.Set( des, NULL, NULL );
       
   992 
       
   993     //
       
   994     // It is valid to have a "\" character in a url, but parsing fails,
       
   995     // switch these characters to "/" for the local string and try parsing again.
       
   996     //
       
   997     if ( err == KErrBadName )
       
   998     {
       
   999         int backsashPos = des.LocateF('\\');
       
  1000 
       
  1001         if( backsashPos != KErrNotFound )
       
  1002         {
       
  1003             HBufC* fileName = NULL;
       
  1004 
       
  1005             TRAP( err,  fileName = des.AllocL() );
       
  1006 
       
  1007             if ( err == KErrNone )
       
  1008             {
       
  1009                 int count( fileName->Des().Length() );
       
  1010 
       
  1011                 for ( int j = backsashPos ; j < count; ++j )
       
  1012                 {
       
  1013                     if ( fileName->Des()[j]== '\\' )
       
  1014                     {
       
  1015                         fileName->Des()[j]='/';
       
  1016                     }
       
  1017                 }
       
  1018                 err = filePath.Set( fileName->Des(), NULL, NULL );
       
  1019             }
       
  1020 
       
  1021             if ( fileName )
       
  1022             {
       
  1023                 delete fileName;
       
  1024                 fileName = NULL;
       
  1025             }
       
  1026         }
       
  1027     }
       
  1028 
       
  1029     if ( err == KErrNone )
       
  1030     {
       
  1031         //
       
  1032         // The requirement to support arguments with the extension in streaming links
       
  1033         // for-ex: /video.3gp?start=10&end=40 will have to supported
       
  1034         // as well. So just by doing p.Ext() would retrieve all the string
       
  1035         // after "." so by doing a Left(2) would retrieve only
       
  1036         // .3g or .rm and so on. This would help better
       
  1037         // interpret the extension and decide the branding accordingly
       
  1038         //
       
  1039         filePath.Set( filePath.NameAndExt(), NULL, NULL );
       
  1040         TPtrC extension = filePath.Ext().Left( 2 );
       
  1041 
       
  1042         TBuf<2> buf;
       
  1043         buf.Format( extension );
       
  1044         buf.UpperCase();
       
  1045 
       
  1046         // RealMedia Branding
       
  1047         if ( ! buf.Compare( KMPXRMEXT ) )
       
  1048         {
       
  1049             realFormat = true;
       
  1050         }
       
  1051     }
       
  1052 
       
  1053     MPX_DEBUG(_L("VideoPlaybackControlsController::realFormatForStreaming()[%d]"), realFormat);
       
  1054 
       
  1055     return realFormat;
       
  1056 }
       
  1057 
       
  1058 // -------------------------------------------------------------------------------------------------
       
  1059 // VideoPlaybackControlsController::realFormatForLocal()
       
  1060 // -------------------------------------------------------------------------------------------------
       
  1061 //
       
  1062 bool VideoPlaybackControlsController::realFormatForLocal()
       
  1063 {
       
  1064     bool realFormat = false;
       
  1065 
       
  1066     QString real( "real" );
       
  1067     QString rn( "rn" );
       
  1068 
       
  1069     if ( mFileDetails->mMimeType.contains( real, Qt::CaseInsensitive ) ||
       
  1070          mFileDetails->mMimeType.contains( rn, Qt::CaseInsensitive ) )
       
  1071     {
       
  1072         realFormat = true;
       
  1073     }
       
  1074 
       
  1075     MPX_DEBUG(_L("VideoPlaybackControlsController::realFormatForLocal() [%d]"), realFormat);
       
  1076 
       
  1077     return realFormat;
       
  1078 }
       
  1079 
       
  1080 // -------------------------------------------------------------------------------------------------
       
  1081 //   VideoPlaybackControlsController::setDownloadSize()
       
  1082 // -------------------------------------------------------------------------------------------------
       
  1083 //
       
  1084 void VideoPlaybackControlsController::setDownloadSize( int size )
       
  1085 {
       
  1086     MPX_DEBUG(_L("VideoPlaybackControlsController::setDownloadSize() [%d]"), size);
       
  1087 
       
  1088     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1089     {
       
  1090         if ( mControls[i]->setDownloadSize( size ) )
       
  1091         {
       
  1092             break;
       
  1093         }
       
  1094     }
       
  1095 }
       
  1096 
       
  1097 // -------------------------------------------------------------------------------------------------
       
  1098 //   VideoPlaybackControlsController::updateDownloadPosition()
       
  1099 // -------------------------------------------------------------------------------------------------
       
  1100 //
       
  1101 void VideoPlaybackControlsController::updateDownloadPosition( int size )
       
  1102 {
       
  1103     MPX_DEBUG(_L("VideoPlaybackControlsController::updateDownloadPosition() [%d]"), size);
       
  1104 
       
  1105     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1106     {
       
  1107         if ( mControls[i]->updateDownloadPosition( size ) )
       
  1108         {
       
  1109             break;
       
  1110         }
       
  1111     }
       
  1112 }
       
  1113 
       
  1114 // -------------------------------------------------------------------------------------------------
       
  1115 // VideoPlaybackControlsController::handleErrors
       
  1116 // -------------------------------------------------------------------------------------------------
       
  1117 //
       
  1118 void VideoPlaybackControlsController::handleErrors()
       
  1119 {
       
  1120     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::handleErrors()"),
       
  1121                    _L("mState = %d"), mState );
       
  1122 }
       
  1123 
       
  1124 // -------------------------------------------------------------------------------------------------
       
  1125 //   VideoPlaybackControlsController::isSoftKeyVisible()
       
  1126 // -------------------------------------------------------------------------------------------------
       
  1127 //
       
  1128 bool VideoPlaybackControlsController::isSoftKeyVisible()
       
  1129 {
       
  1130     bool visible = false;
       
  1131 
       
  1132     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1133     {
       
  1134         if ( mControls[i]->controlIndex() == EStatusPane )
       
  1135         {
       
  1136             if ( mControls[i]->isVisible() )
       
  1137             {
       
  1138                 visible = true;
       
  1139             }
       
  1140 
       
  1141             break;
       
  1142         }
       
  1143     }
       
  1144 
       
  1145     MPX_DEBUG(_L("VideoPlaybackControlsController::isSoftKeyVisible() [%d]"), visible);
       
  1146 
       
  1147     return visible;
       
  1148 }
       
  1149 
       
  1150 // -------------------------------------------------------------------------------------------------
       
  1151 //   VideoPlaybackControlsController::handleTvOutEvent
       
  1152 // -------------------------------------------------------------------------------------------------
       
  1153 //
       
  1154 void VideoPlaybackControlsController::handleTvOutEvent(
       
  1155         bool connected, TVideoPlaybackControlCommandIds event )
       
  1156 {
       
  1157     Q_UNUSED( event );
       
  1158 
       
  1159     MPX_DEBUG(_L("VideoPlaybackControlsController::handleTvOutEvent()"));
       
  1160 
       
  1161     mFileDetails->mTvOutConnected = connected;
       
  1162 
       
  1163     setDefaultBitmap();
       
  1164 
       
  1165     if ( mFileDetails->mTvOutConnected )
       
  1166     {
       
  1167         generateThumbNail();
       
  1168     }
       
  1169 
       
  1170     //
       
  1171     // Change the view.
       
  1172     // If Tv-out is connected, go to AudioOnlyView.
       
  1173     // If not, go back to default view.
       
  1174     //
       
  1175     TPlaybackViewMode viewMode = EFullScreenView;
       
  1176 
       
  1177     if ( mFileDetails->mTvOutConnected || ! mFileDetails->mVideoEnabled )
       
  1178     {
       
  1179         viewMode = EAudioOnlyView;
       
  1180     }
       
  1181 
       
  1182     changeViewMode( viewMode, false );
       
  1183 }
       
  1184 
       
  1185 // -------------------------------------------------------------------------------------------------
       
  1186 //   VideoPlaybackControlsController::changeViewMode
       
  1187 // -------------------------------------------------------------------------------------------------
       
  1188 //
       
  1189 void VideoPlaybackControlsController::changeViewMode(
       
  1190         TPlaybackViewMode viewMode, bool transitionEffect )
       
  1191 {
       
  1192     MPX_DEBUG(_L("VideoPlaybackControlsController::changeViewMode( %d, %d )"),
       
  1193             viewMode, transitionEffect );
       
  1194 
       
  1195     if ( viewMode != mViewMode )
       
  1196     {
       
  1197         switch ( viewMode )
       
  1198         {
       
  1199             case EFullScreenView:
       
  1200             case EDetailsView:
       
  1201             {
       
  1202                 if ( mFileDetails->mVideoEnabled && ! mFileDetails->mTvOutConnected )
       
  1203                 {
       
  1204                     mViewMode = viewMode;
       
  1205 
       
  1206                     //
       
  1207                     // Hack to clean up the screen before transition. We may not need it in NGA env
       
  1208                     //
       
  1209                     hideAllControls();
       
  1210 
       
  1211                     updateVideoRect( transitionEffect );
       
  1212                 }
       
  1213 
       
  1214                 break;
       
  1215             }
       
  1216             case EAudioOnlyView:
       
  1217             {
       
  1218                 if ( ! mFileDetails->mVideoEnabled || mFileDetails->mTvOutConnected )
       
  1219                 {
       
  1220                     mViewMode = viewMode;
       
  1221 
       
  1222                     mControlsConfig->updateControlList( EControlCmdAudionOnlyViewOpened );
       
  1223                 }
       
  1224 
       
  1225                 break;
       
  1226             }
       
  1227             default:
       
  1228             {
       
  1229                 break;
       
  1230             }
       
  1231         }
       
  1232     }
       
  1233 }
       
  1234 
       
  1235 // -------------------------------------------------------------------------------------------------
       
  1236 //   VideoPlaybackControlsController::updateVideoRectDone
       
  1237 // -------------------------------------------------------------------------------------------------
       
  1238 //
       
  1239 void VideoPlaybackControlsController::updateVideoRectDone()
       
  1240 {
       
  1241     MPX_DEBUG(_L("VideoPlaybackControlsController::updateVideoRectDone()"));
       
  1242 
       
  1243     mViewTransitionIsGoingOn = false;
       
  1244 
       
  1245     TVideoPlaybackControlCommandIds event = EControlCmdFullScreenViewOpened;
       
  1246 
       
  1247     if ( mViewMode == EDetailsView )
       
  1248     {
       
  1249         event = EControlCmdDetailsViewOpened;
       
  1250     }
       
  1251 
       
  1252     mControlsConfig->updateControlList( event );
       
  1253 }
       
  1254 
       
  1255 // -------------------------------------------------------------------------------------------------
       
  1256 //   VideoPlaybackControlsController::skipToPreviousVideoItem
       
  1257 // -------------------------------------------------------------------------------------------------
       
  1258 //
       
  1259 void VideoPlaybackControlsController::skipToPreviousVideoItem()
       
  1260 {
       
  1261     MPX_DEBUG(_L("VideoPlaybackControlsController::skipToPreviousVideoItem()"));
       
  1262 
       
  1263     if ( mViewMode == EFullScreenView )
       
  1264     {
       
  1265         handleCommand( EMPXPbvCmdPreviousListItem );
       
  1266     }
       
  1267 }
       
  1268 
       
  1269 // -------------------------------------------------------------------------------------------------
       
  1270 //   VideoPlaybackControlsController::skipToNextVideoItem
       
  1271 // -------------------------------------------------------------------------------------------------
       
  1272 //
       
  1273 void VideoPlaybackControlsController::skipToNextVideoItem()
       
  1274 {
       
  1275     MPX_DEBUG(_L("VideoPlaybackControlsController::skipToNextVideoItem()"));
       
  1276 
       
  1277     if ( mViewMode == EFullScreenView )
       
  1278     {
       
  1279         handleCommand( EMPXPbvCmdNextListItem );
       
  1280     }
       
  1281 }
       
  1282 
       
  1283 // -------------------------------------------------------------------------------------------------
       
  1284 //   VideoPlaybackControlsController::updateVideoRect()
       
  1285 // -------------------------------------------------------------------------------------------------
       
  1286 //
       
  1287 void VideoPlaybackControlsController::updateVideoRect( bool transitionEffect )
       
  1288 {
       
  1289     MPX_DEBUG(_L("VideoPlaybackControlsController::updateVideoRect( %d )"),
       
  1290             transitionEffect );
       
  1291 
       
  1292     if ( mFileDetails->mVideoEnabled && ! mFileDetails->mTvOutConnected )
       
  1293     {
       
  1294         mViewTransitionIsGoingOn = true;
       
  1295 
       
  1296         QRectF rect;
       
  1297 
       
  1298         MPX_DEBUG(_L("VideoPlaybackControlsController::updateVideoRect() : mViewMode = %d )"),
       
  1299                 mViewMode );
       
  1300 
       
  1301         if ( mViewMode == EDetailsView )
       
  1302         {
       
  1303             QGraphicsWidget *parent = mLoader->findWidget( QString( "detailsPlaybackWindow" ) );
       
  1304             QGraphicsWidget *child = mLoader->findWidget( QString( "small_transparentWindow" ) );
       
  1305 
       
  1306             rect = parent->mapRectToScene( child->geometry() );
       
  1307         }
       
  1308         else if ( mViewMode == EFullScreenView )
       
  1309         {
       
  1310             QGraphicsWidget *widget = mLoader->findWidget( QString( "content" ) );
       
  1311             rect = widget->geometry();
       
  1312         }
       
  1313 
       
  1314         mViewWrapper->UpdateVideoRect(
       
  1315                 rect.x(), rect.y(), rect.width(), rect.height(), transitionEffect );
       
  1316     }
       
  1317 }
       
  1318 
       
  1319 // -------------------------------------------------------------------------------------------------
       
  1320 //   VideoPlaybackControlsController::setDefaultBitmap()
       
  1321 // -------------------------------------------------------------------------------------------------
       
  1322 //
       
  1323 void VideoPlaybackControlsController::setDefaultBitmap()
       
  1324 {
       
  1325     MPX_DEBUG(_L("VideoPlaybackControlsController::setDefaultBitmap()"));
       
  1326 
       
  1327     //
       
  1328     // set specific bitmaps for audio only and tv out cases
       
  1329     // If we already requested a thumbnail, we will set the thumbnail after we receive the thumbnail
       
  1330     //
       
  1331     if ( mLoader && mThumbNailState != EThumbNailRequsted )
       
  1332     {
       
  1333         QGraphicsWidget *tvOutBitmap = mLoader->findWidget( "tvOutBitmap" );
       
  1334         tvOutBitmap->setVisible( false );
       
  1335 
       
  1336         QGraphicsWidget *realAudioOnlyBitmap = mLoader->findWidget( "realAudioOnlyBitmap" );
       
  1337         realAudioOnlyBitmap->setVisible( false );
       
  1338 
       
  1339         QGraphicsWidget *partialAudioOnlyBitmap = mLoader->findWidget( "partialAudioOnlyBitmap" );
       
  1340         partialAudioOnlyBitmap->setVisible( false );
       
  1341 
       
  1342         QGraphicsWidget *audioOnlyBitmap = mLoader->findWidget( "audioOnlyBitmap" );
       
  1343         audioOnlyBitmap->setVisible( false );
       
  1344 
       
  1345         if ( mFileDetails->mTvOutConnected )
       
  1346         {
       
  1347             tvOutBitmap->setVisible( true );
       
  1348         }
       
  1349         else if ( mFileDetails->mRNFormat )
       
  1350         {
       
  1351             realAudioOnlyBitmap->setVisible( true );
       
  1352         }
       
  1353         else if ( mFileDetails->mPartialPlayback )
       
  1354         {
       
  1355             partialAudioOnlyBitmap->setVisible( true );
       
  1356         }
       
  1357         else
       
  1358         {
       
  1359             audioOnlyBitmap->setVisible( true );
       
  1360         }
       
  1361     }
       
  1362 }
       
  1363 
       
  1364 // -------------------------------------------------------------------------------------------------
       
  1365 //   VideoPlaybackControlsController::generateThumbNail()
       
  1366 // -------------------------------------------------------------------------------------------------
       
  1367 //
       
  1368 void VideoPlaybackControlsController::generateThumbNail()
       
  1369 {
       
  1370     MPX_DEBUG(_L("VideoPlaybackControlsController::generateThumbNail()"));
       
  1371 
       
  1372     //
       
  1373     // Generate thumbnail if it is local playback
       
  1374     //
       
  1375     if ( mFileDetails->mPlaybackMode == EMPXVideoLocal )
       
  1376     {
       
  1377         if ( mThumbNailState == EThumbNailEmpty )
       
  1378         {
       
  1379             mThumbnailManager = new ThumbnailManager(); ;
       
  1380 
       
  1381             mThumbnailManager->setThumbnailSize( ThumbnailManager::ThumbnailLarge );
       
  1382             mThumbnailManager->setQualityPreference( ThumbnailManager::OptimizeForPerformance );
       
  1383 
       
  1384             if ( connect( mThumbnailManager, SIGNAL( thumbnailReady( QPixmap , void * , int , int ) ),
       
  1385                           this, SLOT( handleThumbnailReady( QPixmap , void * , int , int ) ) ) )
       
  1386             {
       
  1387                 mThumbnailManager->getThumbnail( mFileDetails->mClipName );
       
  1388                 mThumbNailState = EThumbNailRequsted;
       
  1389             }
       
  1390         }
       
  1391     }
       
  1392     else
       
  1393     {
       
  1394         mThumbNailState = EThumbNailNotAvailable;
       
  1395     }
       
  1396 }
       
  1397 
       
  1398 // -------------------------------------------------------------------------------------------------
       
  1399 // VideoPlaybackControlsController::handleThumbnailReady()
       
  1400 // -------------------------------------------------------------------------------------------------
       
  1401 //
       
  1402 void VideoPlaybackControlsController::handleThumbnailReady(
       
  1403         QPixmap tnData, void *internal , int id, int error )
       
  1404 {
       
  1405     Q_UNUSED( internal );
       
  1406     Q_UNUSED( id );
       
  1407 
       
  1408     if( ! error && mLoader )
       
  1409     {
       
  1410         QGraphicsWidget *tvOutBitmap = mLoader->findWidget( "tvOutBitmap" );
       
  1411         HbLabel *tvOutLabel = qobject_cast<HbLabel*>( tvOutBitmap );
       
  1412 
       
  1413         QIcon *qicon = new QIcon( tnData );
       
  1414 
       
  1415         HbIcon *hbIcon = new HbIcon( *qicon );
       
  1416         hbIcon->setSize( tvOutBitmap->size() );
       
  1417         tvOutLabel->setIcon( *hbIcon );
       
  1418 
       
  1419         mThumbNailState = EThumbNailSet;
       
  1420     }
       
  1421     else
       
  1422     {
       
  1423         mThumbNailState = EThumbNailNotAvailable;
       
  1424     }
       
  1425 
       
  1426     setDefaultBitmap();
       
  1427 
       
  1428     disconnect( mThumbnailManager, SIGNAL( thumbnailReady( QPixmap , void * , int , int ) ),
       
  1429                 this, SLOT( handleThumbnailReady( QPixmap , void * , int , int ) ) );
       
  1430 }
       
  1431 
       
  1432 // -------------------------------------------------------------------------------------------------
       
  1433 // VideoPlaybackControlsController::attachVideo()
       
  1434 // -------------------------------------------------------------------------------------------------
       
  1435 //
       
  1436 void VideoPlaybackControlsController::attachVideo()
       
  1437 {
       
  1438     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::attachVideo()"),
       
  1439                    _L("file = %s"), mFileDetails->mClipName.data() );
       
  1440 
       
  1441     //
       
  1442     // close playback view
       
  1443     //
       
  1444     mView->closePlaybackView();
       
  1445 
       
  1446     //
       
  1447     // emit signal to launch videoservices itemSelected() slot
       
  1448     //
       
  1449     emit( attachVideoPath( mFileDetails->mClipName ) );
       
  1450 
       
  1451 }
       
  1452 
       
  1453 // -------------------------------------------------------------------------------------------------
       
  1454 // VideoPlaybackControlsController::sendVideo()
       
  1455 // -------------------------------------------------------------------------------------------------
       
  1456 //
       
  1457 void VideoPlaybackControlsController::sendVideo()
       
  1458 {
       
  1459     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::sendVideo()"),
       
  1460                    _L("file = %s"), mFileDetails->mClipName.data() );
       
  1461 
       
  1462     //
       
  1463     // pause playback
       
  1464     //
       
  1465     handleCommand( EMPXPbvCmdPause );
       
  1466 
       
  1467     //
       
  1468     // send video to shareUI
       
  1469     //
       
  1470     ShareUi dlg;
       
  1471     QStringList fileList;
       
  1472     fileList.append( mFileDetails->mClipName );
       
  1473     dlg.send( fileList, true );
       
  1474 }
       
  1475 
       
  1476 // -------------------------------------------------------------------------------------------------
       
  1477 // VideoPlaybackControlsController::handleRNLogoVisibleChanged()
       
  1478 // -------------------------------------------------------------------------------------------------
       
  1479 //
       
  1480 void VideoPlaybackControlsController::handleRNLogoVisibleChanged()
       
  1481 {
       
  1482     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::handleRNLogoVisibleChanged()"));
       
  1483 
       
  1484     QGraphicsWidget *widget = mLoader->findWidget( QString( "rnLogoBitmap" ) );
       
  1485 
       
  1486     if ( widget->isVisible() )
       
  1487     {
       
  1488         if ( mRNLogoTimer )
       
  1489         {
       
  1490             delete mRNLogoTimer;
       
  1491             mRNLogoTimer = NULL;
       
  1492         }
       
  1493 
       
  1494         mRNLogoTimer = new QTimer( this );
       
  1495         mRNLogoTimer->setInterval( KRNLogoTimeOut );
       
  1496         mRNLogoTimer->setSingleShot( true );
       
  1497         connect( mRNLogoTimer, SIGNAL( timeout() ), this, SLOT( handleRNLogoTimeout() ) );
       
  1498 
       
  1499         mRNLogoTimer->start();
       
  1500     }
       
  1501 }
       
  1502 
       
  1503 // -------------------------------------------------------------------------------------------------
       
  1504 // VideoPlaybackControlsController::handleRNLogoTimeout()
       
  1505 // -------------------------------------------------------------------------------------------------
       
  1506 //
       
  1507 void VideoPlaybackControlsController::handleRNLogoTimeout()
       
  1508 {
       
  1509     MPX_DEBUG(_L("VideoPlaybackControlsController::handleRNLogoTimeout()"));
       
  1510 
       
  1511     if ( mRNLogoTimer->isActive() )
       
  1512     {
       
  1513         mRNLogoTimer->stop();
       
  1514     }
       
  1515 
       
  1516     //
       
  1517     // Remove RN logo from the controls list and issue play command if needed
       
  1518     //
       
  1519     mControlsConfig->updateControlList( EControlCmdRemoveRNLogo );
       
  1520     handleCommand( EMPXPbvCmdRealOneBitmapTimeout );
       
  1521 }
       
  1522 
       
  1523 // -------------------------------------------------------------------------------------------------
       
  1524 // VideoPlaybackControlsController::isRNLogoBitmapInControlList()
       
  1525 // -------------------------------------------------------------------------------------------------
       
  1526 //
       
  1527 bool VideoPlaybackControlsController::isRNLogoBitmapInControlList()
       
  1528 {
       
  1529     bool exist = false;
       
  1530 
       
  1531     //
       
  1532     // If we have a rn logo in the list, we are supposed to show the logo all the time
       
  1533     // unless we are in the middle of orientation transition
       
  1534     //
       
  1535     for ( int i = 0 ; i < mControls.count() ; i++ )
       
  1536     {
       
  1537         if ( mControls[i]->controlIndex() == ERealLogoBitmap )
       
  1538         {
       
  1539             exist = true;
       
  1540             break;
       
  1541         }
       
  1542     }
       
  1543 
       
  1544     MPX_DEBUG(_L("VideoPlaybackControlsController::isRNLogoBitmapInControlList() [%d]"), exist);
       
  1545 
       
  1546     return exist;
       
  1547 }
       
  1548 
       
  1549 // -------------------------------------------------------------------------------------------------
       
  1550 // VideoPlaybackControlsController::handleOrientationChanged()
       
  1551 // -------------------------------------------------------------------------------------------------
       
  1552 //
       
  1553 void VideoPlaybackControlsController::handleOrientationChanged( Qt::Orientation orientation )
       
  1554 {
       
  1555     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::handleOrientationChanged()"),
       
  1556                    _L("old orientation %d, new orientation = %d"), mOrientation, orientation );
       
  1557 
       
  1558     Qt::Orientation  oldOrientaiton = mOrientation;
       
  1559     mOrientation = orientation;
       
  1560 
       
  1561     if ( oldOrientaiton == Qt::Vertical && orientation == Qt::Horizontal )
       
  1562     {
       
  1563         showControls();
       
  1564     }
       
  1565 }
       
  1566 
       
  1567 // -------------------------------------------------------------------------------------------------
       
  1568 // VideoPlaybackControlsController::shouldShowRNLogo()
       
  1569 // -------------------------------------------------------------------------------------------------
       
  1570 //
       
  1571 bool VideoPlaybackControlsController::shouldShowRNLogo()
       
  1572 {
       
  1573     MPX_ENTER_EXIT(_L("VideoPlaybackControlsController::shouldShowRNLogo()"));
       
  1574 
       
  1575     bool showRNLogo = false;
       
  1576     
       
  1577     if ( mFileDetails->mRNFormat &&  
       
  1578          !mViewWrapper->IsResumingPlaybackAfterTermination() )
       
  1579     {
       
  1580         showRNLogo = true;
       
  1581     }
       
  1582      
       
  1583     return showRNLogo;
       
  1584 }
       
  1585 
       
  1586 // End of File