videoplayback/hbvideoplaybackview/viewsrc/hbvideobaseplaybackview.cpp
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 36 8aed59de29f9
equal deleted inserted replaced
34:bbb98528c666 35:3738fe97f027
    13 *
    13 *
    14 * Description:   Implementation of Video base playback view
    14 * Description:   Implementation of Video base playback view
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: da1mmcf#30 %
    18 // Version : %version: da1mmcf#32 %
    19 
    19 
    20 
    20 
    21 
    21 
    22 //  Include Files
    22 //  Include Files
    23 
    23 
    29 #include <hbmenu.h>
    29 #include <hbmenu.h>
    30 #include <hbaction.h>
    30 #include <hbaction.h>
    31 #include <hbgesture.h>
    31 #include <hbgesture.h>
    32 #include <hbinstance.h>
    32 #include <hbinstance.h>
    33 #include <hbnotificationdialog.h>
    33 #include <hbnotificationdialog.h>
       
    34 #include <hblabel.h>
    34 
    35 
    35 #include <textresolver.h>
    36 #include <textresolver.h>
    36 #include <mmf/common/mmferrors.h>
    37 #include <mmf/common/mmferrors.h>
    37 #include <DRMHelper.h>
    38 #include <DRMHelper.h>
    38 
    39 
    64 //   HbVideoBasePlaybackView::initializeVideoPlaybackView()
    65 //   HbVideoBasePlaybackView::initializeVideoPlaybackView()
    65 // -------------------------------------------------------------------------------------------------
    66 // -------------------------------------------------------------------------------------------------
    66 //
    67 //
    67 void HbVideoBasePlaybackView::initializeVideoPlaybackView()
    68 void HbVideoBasePlaybackView::initializeVideoPlaybackView()
    68 {
    69 {
    69     MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::initializeVideoPlaybackView()"));
    70     MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::initializeVideoPlaybackView()"));  
    70 
    71       
    71     //
    72     //
    72     // Need to set to control full screen including status pane area
    73     // Need to set to control full screen including status pane area
    73     //
    74     //
    74     setContentFullScreen();
    75     setContentFullScreen();
    75 
    76 
    98 
    99 
    99         delete mTimerForClosingView;
   100         delete mTimerForClosingView;
   100         mTimerForClosingView = NULL;
   101         mTimerForClosingView = NULL;
   101     }
   102     }
   102 
   103 
   103     if ( mVideoMpxWrapper )
       
   104     {
       
   105         delete mVideoMpxWrapper;
       
   106         mVideoMpxWrapper = NULL;
       
   107     }
       
   108 
   104 
   109     setParentItem( 0 );
   105     setParentItem( 0 );
   110 }
   106 }
   111 
   107 
   112 // -------------------------------------------------------------------------------------------------
   108 // -------------------------------------------------------------------------------------------------
   114 // -------------------------------------------------------------------------------------------------
   110 // -------------------------------------------------------------------------------------------------
   115 //
   111 //
   116 void HbVideoBasePlaybackView::handleActivateView()
   112 void HbVideoBasePlaybackView::handleActivateView()
   117 {
   113 {
   118     MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleActivateView()"));
   114     MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleActivateView()"));
   119 
   115     
       
   116     TRAP_IGNORE( mVideoMpxWrapper = CMPXVideoViewWrapper::NewL( this ) ); 
       
   117     
       
   118     //
       
   119     //  Request the needed Media from the Playback Plugin
       
   120     //
       
   121     TRAP_IGNORE( mVideoMpxWrapper->RequestMediaL() ); 
       
   122     
   120     menu()->close();
   123     menu()->close();
   121 
   124 
   122     hideItems( Hb::AllItems );
   125     hideItems( Hb::AllItems );
   123 
   126 
   124     //
   127     //
   125     // Landscape orientation
   128     // Landscape orientation
   126     //
   129     //
   127     hbInstance->allMainWindows()[0]->setOrientation( Qt::Horizontal );
   130     hbInstance->allMainWindows()[0]->setOrientation( Qt::Horizontal );  
   128 
   131 
   129     TRAP_IGNORE( mVideoMpxWrapper = CMPXVideoViewWrapper::NewL( this ) );
   132     mActivated = true;   
   130 
   133        
   131     mActivated = true;
       
   132 
       
   133     //
       
   134     //  Retrieve PDL information for container
       
   135     //
       
   136     retrievePdlInformation();
       
   137 
       
   138     //
       
   139     //  Request the needed Media from the Playback Plugin
       
   140     //
       
   141     TRAP_IGNORE( mVideoMpxWrapper->RequestMediaL() );
       
   142 }
   134 }
   143 
   135 
   144 // -------------------------------------------------------------------------------------------------
   136 // -------------------------------------------------------------------------------------------------
   145 //   HbVideoBasePlaybackView::handleDeactivateView()
   137 //   HbVideoBasePlaybackView::handleDeactivateView()
   146 // -------------------------------------------------------------------------------------------------
   138 // -------------------------------------------------------------------------------------------------
   208         case KErrMMDRMNotAuthorized:
   200         case KErrMMDRMNotAuthorized:
   209         case KErrCANoRights:
   201         case KErrCANoRights:
   210         case KErrCANoPermission:
   202         case KErrCANoPermission:
   211         {
   203         {
   212             const QString qString = "License has expired or it is missing";
   204             const QString qString = "License has expired or it is missing";
   213             displayErrorMessage( qString );
   205             showDialog( qString );
   214             handleClosePlaybackView();
       
   215             break;
   206             break;
   216         }
   207         }
   217         case KMPXVideoCallOngoingError:
   208         case KMPXVideoCallOngoingError:
   218         {
   209         {
   219             const QString qString = "FMP cannot be used during video call";
   210             const QString qString = "Video playback is not allowed during video call";
   220             displayInfoMessage( qString );
   211             showDialog( qString, false );
   221             break;
   212             break;
   222         }
   213         }
   223         case KMPXVideoTvOutPlaybackNotAllowed:
   214         case KMPXVideoTvOutPlaybackNotAllowed:
   224         {
   215         {
   225             const QString qString = "Protected clip, can not be played through TV-Out";
   216             const QString qString = "Protected clip, can not be played through TV-Out";
   226             displayInfoMessage( qString );
   217             showDialog( qString, false );
   227             break;
   218             break;
   228         }
   219         }
   229         case KMPXVideoTvOutPlaybackNotAllowedClose:
   220         case KMPXVideoTvOutPlaybackNotAllowedClose:
   230         {
   221         {
   231             const QString qString = "Protected clip, can not be played through TV-Out";
   222             const QString qString = "Protected clip, can not be played through TV-Out";
   232             displayInfoMessage( qString );
   223             showDialog( qString );
   233             handleClosePlaybackView();
       
   234             break;
   224             break;
   235         }
   225         }
   236         default:
   226         default:
   237         {
   227         {
   238             TRAP_IGNORE(  
   228             TRAP_IGNORE(  
   250     
   240     
   251                 //
   241                 //
   252                 // convert to QString
   242                 // convert to QString
   253                 //
   243                 //
   254                 const QString qString( (QChar*)text.Ptr(), text.Length() );
   244                 const QString qString( (QChar*)text.Ptr(), text.Length() );
   255                 displayErrorMessage( qString );
   245                 
   256     
   246                 //
       
   247                 // clean up textresolver
       
   248                 //
   257                 CleanupStack::PopAndDestroy( textresolver );
   249                 CleanupStack::PopAndDestroy( textresolver );
   258     
   250 
   259                 handleClosePlaybackView();
   251                 //
   260             
   252                 // display error and close playback view
       
   253                 //
       
   254                 showDialog( qString );
       
   255     
   261             );
   256             );
   262         }
   257         }
   263     }
   258     }
   264 }
   259 }
   265 
   260 
   266 // -------------------------------------------------------------------------------------------------
   261 // -------------------------------------------------------------------------------------------------
   267 //   HbVideoBasePlaybackView::displayInfoMessage
   262 //   HbVideoBasePlaybackView::showDialog
   268 // -------------------------------------------------------------------------------------------------
   263 // -------------------------------------------------------------------------------------------------
   269 //
   264 //
   270 void HbVideoBasePlaybackView::displayInfoMessage(  const QString& qString )
   265 void HbVideoBasePlaybackView::showDialog( const QString& qString, bool closeView )
   271 {
   266 {
   272     MPX_DEBUG(_L("HbVideoBasePlaybackView::displayInfoMessage()"));
   267     MPX_DEBUG(_L("HbVideoBasePlaybackView::showDialog( %s, %d )"), qString.data(), closeView );
   273 
   268         
   274     HbNotificationDialog::launchDialog( qString );             
   269     //
   275 }
   270     // create pop-up dialog for error notes, 
   276 
   271     //     set its position to the middle of the screen
   277 // -------------------------------------------------------------------------------------------------
   272     //     and make sure pop-up dialog gets deleted on close.
   278 //   HbVideoBasePlaybackView::displayErrorMessage
   273     //
   279 // -------------------------------------------------------------------------------------------------
   274     QRectF screenRect = hbInstance->allMainWindows()[0]->rect();
   280 //
   275     HbNotificationDialog* dlg = new HbNotificationDialog();    
   281 void HbVideoBasePlaybackView::displayErrorMessage( const QString& qString )
   276     dlg->setAttribute( Qt::WA_DeleteOnClose );
   282 {
   277     dlg->setMinimumSize( QSizeF(200, 100) );    
   283     MPX_DEBUG(_L("HbVideoBasePlaybackView::displayErrorMessage()"));
   278     dlg->setPreferredPos( QPointF( screenRect.height()/2, screenRect.width()/2 ), 
   284 
   279                           HbPopup::Center );
   285     HbNotificationDialog::launchDialog( qString );
   280     
       
   281 	if ( closeView )
       
   282 	{
       
   283         //
       
   284         // connect aboutToClose() signal to handleClosePopupDialog() slot so that
       
   285         // when pop-up dialog is closed, playback view is closed also
       
   286         //
       
   287         connect( dlg, SIGNAL( aboutToClose() ), this, SLOT( handleClosePopupDialog() ) );        
       
   288     }
       
   289 	
       
   290     //
       
   291     // convert string to label so text alignment can be set
       
   292     //
       
   293     HbLabel *label = new HbLabel( qString );
       
   294     label->setAlignment( Qt::AlignCenter );
       
   295     
       
   296     //
       
   297     // set label as content widget and show pop-up dialog
       
   298     //
       
   299     dlg->setContentWidget( label );
       
   300     dlg->show();    
   286 }
   301 }
   287 
   302 
   288 // -------------------------------------------------------------------------------------------------
   303 // -------------------------------------------------------------------------------------------------
   289 //   HbVideoBasePlaybackView::doClosePlayer
   304 //   HbVideoBasePlaybackView::doClosePlayer
   290 // -------------------------------------------------------------------------------------------------
   305 // -------------------------------------------------------------------------------------------------
   395     Q_UNUSED( event );
   410     Q_UNUSED( event );
   396 
   411 
   397     emit tappedOnScreen();
   412     emit tappedOnScreen();
   398 }
   413 }
   399 
   414 
       
   415 // -------------------------------------------------------------------------------------------------
       
   416 //   HbVideoBasePlaybackView::handleClosePopupDialog()
       
   417 // -------------------------------------------------------------------------------------------------
       
   418 //
       
   419 void HbVideoBasePlaybackView::handleClosePopupDialog()
       
   420 {
       
   421     MPX_DEBUG(_L("HbVideoBasePlaybackView::handleClosePopupDialog()") );
       
   422 
       
   423     handleClosePlaybackView();
       
   424 }
       
   425 
       
   426 
   400 // EOF
   427 // EOF