videoplayback/videoplaybackview/viewsrc/mpxvideoviewwrapper.cpp
changeset 66 adb51f74b890
parent 63 4707a0db12f6
equal deleted inserted replaced
63:4707a0db12f6 66:adb51f74b890
    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#48 %
    18 // Version : %version: da1mmcf#52 %
    19 
    19 
    20 
    20 
    21 
    21 
    22 //  Include Files
    22 //  Include Files
    23 
    23 
    24 #include <w32std.h>
    24 #include <w32std.h>
    25 #include <eikenv.h>
    25 #include <eikenv.h>
       
    26 #include <devsoundif.h>
    26 
    27 
    27 #include <mpxplaybackcommanddefs.h>
    28 #include <mpxplaybackcommanddefs.h>
    28 #include <mpxvideoplaybackdefs.h>
    29 #include <mpxvideoplaybackdefs.h>
    29 #include <mpxcommandgeneraldefs.h>
    30 #include <mpxcommandgeneraldefs.h>
    30 #include <mpxcommand.h>
    31 #include <mpxcommand.h>
   125     }
   126     }
   126 
   127 
   127     //
   128     //
   128     //  Create Video Playback Display Handler
   129     //  Create Video Playback Display Handler
   129     //
   130     //
   130     iDisplayHandler = CVideoPlaybackDisplayHandler::NewL( iPlaybackUtility, this );
   131     iDisplayHandler = CVideoPlaybackDisplayHandler::NewL( this );
   131 
   132 
   132     //
   133     //
   133     // Create control's controller
   134     // Create control's controller
   134     //
   135     //
   135     CreateControlsL();
   136     CreateControlsL();
   654                     if ( iPlaybackState != EPbStateNotInitialised )
   655                     if ( iPlaybackState != EPbStateNotInitialised )
   655                     {
   656                     {
   656                         iMediaRequestStatus = MediaNotRequested;
   657                         iMediaRequestStatus = MediaNotRequested;
   657                         HandleCommandL( EMPXPbvCmdResetControls );
   658                         HandleCommandL( EMPXPbvCmdResetControls );
   658 
   659 
   659                         if ( iFileDetails )
   660                         InitializeFileDetails();
   660                         {
       
   661                             iFileDetails->clearFileDetails();
       
   662                         }
       
   663                     }
   661                     }
   664                 }
   662                 }
   665                 break;
   663                 break;
   666             }
   664             }
   667             case EPbStateBuffering:
   665             case EPbStateBuffering:
   950     //
   948     //
   951     if ( aMedia.IsSupported( KMPXMediaVideoLastModified ) )
   949     if ( aMedia.IsSupported( KMPXMediaVideoLastModified ) )
   952     {
   950     {
   953         iFileDetails->mModificationTime = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoLastModified );
   951         iFileDetails->mModificationTime = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoLastModified );
   954     }
   952     }
   955 
       
   956 }
   953 }
   957 
   954 
   958 // -------------------------------------------------------------------------------------------------
   955 // -------------------------------------------------------------------------------------------------
   959 // Handle media properties.
   956 // Handle media properties.
   960 // Notes: The client is responsible for delete the object of aProperties.
   957 // Notes: The client is responsible for delete the object of aProperties.
  1291 {
  1288 {
  1292     MPX_ENTER_EXIT(_L("CMPXVideoViewWrapper::IssueVideoAppForegroundCmdL()"),
  1289     MPX_ENTER_EXIT(_L("CMPXVideoViewWrapper::IssueVideoAppForegroundCmdL()"),
  1293                    _L("aViewForeground = %d, aAppForegournd = %d"), aViewForeground, aAppForegournd );
  1290                    _L("aViewForeground = %d, aAppForegournd = %d"), aViewForeground, aAppForegournd );
  1294 
  1291 
  1295     iUserInputHandler->SetForeground( aAppForegournd );
  1292     iUserInputHandler->SetForeground( aAppForegournd );
  1296     
  1293 
  1297     TMPXVideoPlaybackCommand videoCmd = EPbCmdHandleBackground;
  1294     TMPXVideoPlaybackCommand videoCmd = EPbCmdHandleBackground;
  1298     TVideoPlaybackControlCommandIds controlsCmd = EControlCmdHandleBackgroundEvent;
  1295     TVideoPlaybackControlCommandIds controlsCmd = EControlCmdHandleBackgroundEvent;
  1299 
  1296 
  1300     if ( aViewForeground )
  1297     if ( aViewForeground )
  1301     {
  1298     {
  1326 //
  1323 //
  1327 void CMPXVideoViewWrapper::CreateControlsL()
  1324 void CMPXVideoViewWrapper::CreateControlsL()
  1328 {
  1325 {
  1329     MPX_ENTER_EXIT(_L("CMPXVideoViewWrapper::CreateControlsL()"));
  1326     MPX_ENTER_EXIT(_L("CMPXVideoViewWrapper::CreateControlsL()"));
  1330 
  1327 
  1331     //
  1328     InitializeFileDetails();
  1332     //  Query playback plugin for filename and mode
       
  1333     //
       
  1334     CMPXCommand* cmd = CMPXCommand::NewL();
       
  1335     CleanupStack::PushL( cmd );
       
  1336 
       
  1337     RetrieveFileNameAndModeL( cmd );
       
  1338 
       
  1339     //
       
  1340     //  Create a temporary file details that is populated with the
       
  1341     //  file name and playback mode.  This will be delete when
       
  1342     //  plugin initialization is complete
       
  1343     //
       
  1344     if ( iFileDetails )
       
  1345     {
       
  1346         delete iFileDetails;
       
  1347         iFileDetails = NULL;
       
  1348     }
       
  1349 
       
  1350     iFileDetails = new VideoPlaybackViewFileDetails();
       
  1351 
       
  1352     TPtrC fileName( cmd->ValueText( KMPXMediaVideoPlaybackFileName ) );
       
  1353     const QString qFilename( (QChar*)fileName.Ptr(), fileName.Length() );
       
  1354     iFileDetails->mClipName = qFilename;
       
  1355 
       
  1356     iFileDetails->mPlaybackMode = (TMPXVideoMode) cmd->ValueTObjectL<TInt>( KMPXMediaVideoMode );
       
  1357 
       
  1358     iFileDetails->mTvOutConnected   = cmd->ValueTObjectL<TInt>( KMPXMediaVideoTvOutConnected );
       
  1359 
       
  1360     TPtrC mimeType( cmd->ValueText( KMPXMediaVideoRecognizedMimeType ) );
       
  1361     const QString qMimeType( (QChar*)mimeType.Ptr(), mimeType.Length() );
       
  1362     iFileDetails->mMimeType = qMimeType;
       
  1363 
  1329 
  1364     //
  1330     //
  1365     // get playlist information and set mMultiItemPlaylist flag
  1331     // get playlist information and set mMultiItemPlaylist flag
  1366     //
  1332     //
  1367     TInt numItems = 1;
  1333     TInt numItems = 1;
  1380             delete playlist;
  1346             delete playlist;
  1381         }
  1347         }
  1382     }
  1348     }
  1383 
  1349 
  1384     iFileDetails->mMultiItemPlaylist = ( numItems > 1 );
  1350     iFileDetails->mMultiItemPlaylist = ( numItems > 1 );
  1385 
       
  1386     CleanupStack::PopAndDestroy( cmd );
       
  1387 
  1351 
  1388     if ( iControlsController )
  1352     if ( iControlsController )
  1389     {
  1353     {
  1390         delete iControlsController;
  1354         delete iControlsController;
  1391         iControlsController = NULL;
  1355         iControlsController = NULL;
  1461             //
  1425             //
  1462             // get window size
  1426             // get window size
  1463             //
  1427             //
  1464             RWindow *window = iView->getWindow();
  1428             RWindow *window = iView->getWindow();
  1465             TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) );
  1429             TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) );
  1466 
       
  1467             //
       
  1468             // get window aspect ratio
       
  1469             //   if device is in landscape mode, width > height
       
  1470             //   if device is in portrait mode, width < height
       
  1471             //
       
  1472             TReal32 width = (TReal32) displayRect.Width();
       
  1473             TReal32 height = (TReal32) displayRect.Height();
       
  1474             TReal32 displayAspectRatio = (width > height)? (width / height) : (height / width);
       
  1475 
       
  1476             //
       
  1477             // get new aspect ratio
       
  1478             TInt newAspectRatio =
       
  1479                 iDisplayHandler->SetDefaultAspectRatioL( iFileDetails, displayAspectRatio );
       
  1480 
  1430 
  1481             //
  1431             //
  1482             //  Setup the display window and issue play command
  1432             //  Setup the display window and issue play command
  1483             //
  1433             //
  1484             iDisplayHandler->CreateDisplayWindowL( CCoeEnv::Static()->WsSession(),
  1434             iDisplayHandler->CreateDisplayWindowL( CCoeEnv::Static()->WsSession(),
  1485                                                    *(CCoeEnv::Static()->ScreenDevice()),
  1435                                                    *(CCoeEnv::Static()->ScreenDevice()),
  1486                                                    *window,
  1436                                                    *window,
  1487                                                    displayRect );
  1437                                                    displayRect,
  1488 
  1438                                                    iFileDetails );
  1489             if ( iControlsController )
       
  1490             {
       
  1491                 iControlsController->handleEvent( EControlCmdSetAspectRatio, newAspectRatio );
       
  1492             }
       
  1493         }
  1439         }
  1494 
  1440 
  1495         // if coming back after a forced termination, the playback position must
  1441         // if coming back after a forced termination, the playback position must
  1496         // be restored and state be set to paused, as forced termination can only
  1442         // be restored and state be set to paused, as forced termination can only
  1497         // happen when app is on background, in which case Video Player is paused
  1443         // happen when app is on background, in which case Video Player is paused
  1685     }
  1631     }
  1686 
  1632 
  1687     iControlsController->handleEvent( event );
  1633     iControlsController->handleEvent( event );
  1688 }
  1634 }
  1689 
  1635 
       
  1636 // -------------------------------------------------------------------------------------------------
       
  1637 //   CMPXVideoViewWrapper::VolumeSteps()
       
  1638 // -------------------------------------------------------------------------------------------------
       
  1639 //
       
  1640 int CMPXVideoViewWrapper::VolumeSteps()
       
  1641 {
       
  1642     int volumeSteps = 0;
       
  1643 
       
  1644     TRAP_IGNORE( {
       
  1645         CDevSoundIf* devSoundIf = CDevSoundIf::NewL();
       
  1646         volumeSteps = devSoundIf->GetNumberOfVolumeSteps();
       
  1647         delete devSoundIf;
       
  1648     } );
       
  1649 
       
  1650     MPX_DEBUG(_L("CMPXVideoViewWrapper::VolumeSteps() volumeSteps = %d"), volumeSteps);
       
  1651 
       
  1652     return volumeSteps;
       
  1653 }
       
  1654 
       
  1655 // -------------------------------------------------------------------------------------------------
       
  1656 //   CMPXVideoViewWrapper::InitializeFileDetails()
       
  1657 // -------------------------------------------------------------------------------------------------
       
  1658 //
       
  1659 void CMPXVideoViewWrapper::InitializeFileDetails()
       
  1660 {
       
  1661     MPX_DEBUG(_L("CMPXVideoViewWrapper::InitializeFileDetails()"));
       
  1662 
       
  1663     CMPXCommand* cmd = CMPXCommand::NewL();
       
  1664     CleanupStack::PushL( cmd );
       
  1665 
       
  1666     RetrieveFileNameAndModeL( cmd );
       
  1667 
       
  1668     //
       
  1669     //  Create a temporary file details that is populated with the
       
  1670     //  file name and playback mode.  This will be deleted when
       
  1671     //  plugin initialization is complete
       
  1672     //
       
  1673     if ( !iFileDetails )
       
  1674     {
       
  1675         iFileDetails = new VideoPlaybackViewFileDetails();
       
  1676     }
       
  1677     else
       
  1678     {
       
  1679         iFileDetails->clearFileDetails();
       
  1680     }
       
  1681 
       
  1682     TPtrC fileName( cmd->ValueText( KMPXMediaVideoPlaybackFileName ) );
       
  1683     const QString qFilename( (QChar*)fileName.Ptr(), fileName.Length() );
       
  1684     iFileDetails->mClipName = qFilename;
       
  1685 
       
  1686     iFileDetails->mPlaybackMode = (TMPXVideoMode) cmd->ValueTObjectL<TInt>( KMPXMediaVideoMode );
       
  1687     MPX_DEBUG(_L("CMPXVideoViewWrapper::InitializeFileDetails() - mode %d"), iFileDetails->mPlaybackMode);
       
  1688 
       
  1689     iFileDetails->mTvOutConnected   = cmd->ValueTObjectL<TInt>( KMPXMediaVideoTvOutConnected );
       
  1690 
       
  1691     TPtrC mimeType( cmd->ValueText( KMPXMediaVideoRecognizedMimeType ) );
       
  1692     const QString qMimeType( (QChar*)mimeType.Ptr(), mimeType.Length() );
       
  1693     iFileDetails->mMimeType = qMimeType;
       
  1694 
       
  1695     CleanupStack::PopAndDestroy( cmd );
       
  1696 }
       
  1697 
       
  1698 // -------------------------------------------------------------------------------------------------
       
  1699 //   CMPXVideoViewWrapper::SetDefaultAspectRatio()
       
  1700 // -------------------------------------------------------------------------------------------------
       
  1701 //
       
  1702 void CMPXVideoViewWrapper::SetDefaultAspectRatio( TInt aspectRatio )
       
  1703 {
       
  1704     MPX_DEBUG(_L("CMPXVideoViewWrapper::SetDefaultAspectRatio() aspectRatio = %d"), aspectRatio);
       
  1705 
       
  1706     if ( iControlsController )
       
  1707     {
       
  1708         iControlsController->handleEvent( EControlCmdSetAspectRatio, aspectRatio );
       
  1709     }
       
  1710 }
       
  1711 
  1690 // EOF
  1712 // EOF