mpxplugins/viewplugins/views/commonplaybackview/src/mpxcommonplaybackviewimp.cpp
branchRCL_3
changeset 15 171e07ac910f
parent 14 943ff5625028
child 17 c8156a91d13c
equal deleted inserted replaced
14:943ff5625028 15:171e07ac910f
   111 // CONSTANTS
   111 // CONSTANTS
   112 const TInt KMPXOneSecInMilliSecs( 1000 );
   112 const TInt KMPXOneSecInMilliSecs( 1000 );
   113 const TUid KMPXEqualizerViewImplementationId = { 0x101FFC77 };
   113 const TUid KMPXEqualizerViewImplementationId = { 0x101FFC77 };
   114 const TInt KMPXPostponeForHandleDelayedError( 1000000 ); // 1S
   114 const TInt KMPXPostponeForHandleDelayedError( 1000000 ); // 1S
   115 const TInt KMPXPlaybackViewWindowBackground = -1;
   115 const TInt KMPXPlaybackViewWindowBackground = -1;
       
   116 const TInt KMPXDelayForTNRequest( 3000000 ); // 3S
   116 
   117 
   117 // for freqency display in the format of "XXX.XX"
   118 // for freqency display in the format of "XXX.XX"
   118 const TInt KMPXFMFreqWidth        = 6;
   119 const TInt KMPXFMFreqWidth        = 6;
   119 const TInt KMPXFMFreqDecimalPlace = 2;
   120 const TInt KMPXFMFreqDecimalPlace = 2;
   120 const TInt KMPXOneMhzInOneKhz     = 1000;
   121 const TInt KMPXOneMhzInOneKhz     = 1000;
   157 _LIT(KMPXPnRealAudioMimeType, "audio/x-pn-realaudio");
   158 _LIT(KMPXPnRealAudioMimeType, "audio/x-pn-realaudio");
   158 _LIT(KMPXRealAudioMimeType, "audio/x-realaudio");
   159 _LIT(KMPXRealAudioMimeType, "audio/x-realaudio");
   159 _LIT(KMPXRnRealAudioMimeType, "audio/vnd.rn-realaudio");
   160 _LIT(KMPXRnRealAudioMimeType, "audio/vnd.rn-realaudio");
   160 #endif
   161 #endif
   161 
   162 
       
   163 #define THUMBNAIL_CENREP_UID 0x102830B0 // from thumbnailmanageruids.hrh
       
   164 const TUint32 KSizeAudioFullscreenWidth = 0x16;
       
   165 const TUint32 KSizeAudioFullscreenHeight = 0x17;
   162 
   166 
   163 // ======== MEMBER FUNCTIONS ========
   167 // ======== MEMBER FUNCTIONS ========
   164 
   168 
   165 
   169 
   166 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   207     CRepository* repository( CRepository::NewLC( KCRUidMPXMPFeatures ));
   211     CRepository* repository( CRepository::NewLC( KCRUidMPXMPFeatures ));
   208     User::LeaveIfError( repository->Get( KMPXMPLocalVariation, flags ));
   212     User::LeaveIfError( repository->Get( KMPXMPLocalVariation, flags ));
   209     CleanupStack::PopAndDestroy( repository );
   213     CleanupStack::PopAndDestroy( repository );
   210     repository = NULL;
   214     repository = NULL;
   211 
   215 
       
   216     repository = CRepository::NewLC( TUid::Uid(THUMBNAIL_CENREP_UID));
       
   217 
       
   218     TInt xSize( 0 );
       
   219     TInt ySize( 0 );
       
   220     User::LeaveIfError( repository->Get( KSizeAudioFullscreenWidth, xSize ));
       
   221     User::LeaveIfError( repository->Get( KSizeAudioFullscreenHeight, ySize ));
       
   222     iFullScreenImageSize.SetSize(xSize,ySize);
       
   223     CleanupStack::PopAndDestroy( repository );
       
   224     repository = NULL;
   212 
   225 
   213     iChangeRTForAllProfiles =
   226     iChangeRTForAllProfiles =
   214         static_cast<TBool>( flags & KMPXChangeRTForAll );
   227         static_cast<TBool>( flags & KMPXChangeRTForAll );
   215 
   228 
   216     iLayout = new (ELeave) CMPXCommonPlaybackViewLayout();
   229     iLayout = new (ELeave) CMPXCommonPlaybackViewLayout();
   347         }
   360         }
   348 #endif
   361 #endif
   349     iIsffButtonPressed = EFalse;
   362     iIsffButtonPressed = EFalse;
   350     iDelayedErrorTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   363     iDelayedErrorTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   351     iFmTxActivity = EFmTxStateUnknown;
   364     iFmTxActivity = EFmTxStateUnknown;
       
   365 
       
   366     iTNRequestTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   352     }
   367     }
   353 
   368 
   354 
   369 
   355 // ---------------------------------------------------------------------------
   370 // ---------------------------------------------------------------------------
   356 // Destructor
   371 // Destructor
   460     	iDelayedErrorTimer->Cancel();
   475     	iDelayedErrorTimer->Cancel();
   461     	delete iDelayedErrorTimer;
   476     	delete iDelayedErrorTimer;
   462     	}
   477     	}
   463 
   478 
   464     delete iOldUri;
   479     delete iOldUri;
       
   480     
       
   481     if ( iTNRequestTimer )
       
   482         {
       
   483         iTNRequestTimer->Cancel();
       
   484         delete iTNRequestTimer;
       
   485         }
       
   486     
   465     MPX_DEBUG1( "CMPXCommonPlaybackViewImp::~CMPXCommonPlaybackViewImp exiting" );
   487     MPX_DEBUG1( "CMPXCommonPlaybackViewImp::~CMPXCommonPlaybackViewImp exiting" );
   466     }
   488     }
   467 
   489 
   468 // ---------------------------------------------------------------------------
   490 // ---------------------------------------------------------------------------
   469 // Updates playback view.
   491 // Updates playback view.
   727         if ( aMedia && aMedia->IsSupported(KMPXMediaGeneralUri))
   749         if ( aMedia && aMedia->IsSupported(KMPXMediaGeneralUri))
   728             {
   750             {
   729             const TDesC& album = aMedia->ValueText( KMPXMediaGeneralUri );
   751             const TDesC& album = aMedia->ValueText( KMPXMediaGeneralUri );
   730             if(!iOldUri || iOldUri->Compare(album)!= 0)
   752             if(!iOldUri || iOldUri->Compare(album)!= 0)
   731                 {
   753                 {
   732 
   754                 // Request for pre-generated TN size
   733                 TRect albumArtRect(
   755                 MPX_TRAP( err,
   734                         iLayout->IndicatorLayout(
   756                     iMPXUtility->ExtractAlbumArtL(
   735                                 ClientRect(), EAlbumArtArea ) );
       
   736 
       
   737             MPX_TRAP( err,
       
   738                 iMPXUtility->ExtractAlbumArtL(
       
   739                     *aMedia,
   757                     *aMedia,
   740                     *iContainer,
   758                     *iContainer,
   741                     albumArtRect.Size() ); );
   759                     iFullScreenImageSize ); );
   742                 delete iOldUri;
   760 
   743                 iOldUri = NULL;
   761                 // cancel timer
   744                 iOldUri=album.AllocL();
   762                 if ( iTNRequestTimer->IsActive())
   745                 }
   763                     {
       
   764                     iTNRequestTimer->Cancel();
       
   765                     }
       
   766 
       
   767                 if ( err == KErrNone )
       
   768                     {
       
   769                     // startup timer for updating album art with custom size
       
   770                     TCallBack cb( HandleTNRequestForCustomSizeL, this );
       
   771                     iTNRequestTimer->Start( KMPXDelayForTNRequest,
       
   772                         KMPXDelayForTNRequest,
       
   773                         cb );
       
   774                     }  
       
   775                 }
       
   776             
       
   777             delete iOldUri;
       
   778             iOldUri = NULL;
       
   779             iOldUri = album.AllocL();
   746             }
   780             }
   747 
   781 
   748         if (KErrNone != err )
   782         if (KErrNone != err )
   749             {
   783             {
   750             // If error, show default album art
   784             // If error, show default album art
  2041             #endif // BACKSTEPPING_INCLUDED
  2075             #endif // BACKSTEPPING_INCLUDED
  2042                 {
  2076                 {
  2043                 if ( !iBacking )
  2077                 if ( !iBacking )
  2044                     {
  2078                     {
  2045                     // event not consumed by Back Stepping utility, handle here
  2079                     // event not consumed by Back Stepping utility, handle here
  2046                     //
       
  2047                     // Status pane has to be modified before view gets deactivated
       
  2048 
  2080 
  2049                     MMPXSource* source = iPlaybackUtility->Source();
  2081                     MMPXSource* source = iPlaybackUtility->Source();
  2050                     if ( source )
  2082                     if ( source )
  2051                         {
  2083                         {
  2052                         CMPXCollectionPlaylist* playlist = source->PlaylistL();
  2084                         CMPXCollectionPlaylist* playlist = source->PlaylistL();
  2053                         if ( playlist )
  2085                         if ( playlist )
  2054                             {
  2086                             {
  2055                             CleanupStack::PushL( playlist );
  2087                             CleanupStack::PushL( playlist );
  2056     						CMPXCollectionPath* browsePath( iCollectionUtility->Collection().PathL() );
  2088     						
  2057 							CleanupStack::PushL( browsePath );
       
  2058 					        MPX_DEBUG_PATH(*browsePath);
       
  2059 
       
  2060                             if ( playlist->Count() )
  2089                             if ( playlist->Count() )
  2061                                 {
  2090                                 {
  2062                                 CMPXCollectionPath* pbPath =
  2091                                 CMPXCollectionPath* pbPath = CMPXCollectionPath::NewL( playlist->Path() );
  2063                                     CMPXCollectionPath::NewL( playlist->Path() );
       
  2064                                 CleanupStack::PushL( pbPath );
  2092                                 CleanupStack::PushL( pbPath );
       
  2093                                 pbPath->Back();
       
  2094                                 iViewUtility->PushDefaultHistoryL();
  2065                                 MPX_DEBUG_PATH(*pbPath);
  2095                                 MPX_DEBUG_PATH(*pbPath);
  2066 
  2096                                 iCollectionUtility->Collection().OpenL( *pbPath );
  2067                                 TInt playbackPathCount( pbPath->Levels() );
       
  2068                                 // if both path are at the same level, we need to check further
       
  2069                                 TBool isEqual( ETrue );
       
  2070                                 if ( browsePath->Levels() == playbackPathCount )
       
  2071                                     {
       
  2072                                     // Check id at each level
       
  2073                                     for ( TInt i = 0; i < playbackPathCount - 1; i++ )
       
  2074                                         {
       
  2075                                         if ( browsePath->Id( i ) != pbPath->Id( i ) )
       
  2076                                             {
       
  2077                                             isEqual = EFalse;
       
  2078                                             break;
       
  2079                                             }
       
  2080                                         }
       
  2081                                     }
       
  2082                                 else
       
  2083                                     {
       
  2084                                     isEqual = EFalse;
       
  2085                                     }
       
  2086 
       
  2087                                 if ( isEqual ) // if they're the same path
       
  2088 									{
       
  2089 									pbPath->Back();
       
  2090 									iViewUtility->PushDefaultHistoryL();
       
  2091 									iCollectionUtility->Collection().OpenL( *pbPath );
       
  2092 									}
       
  2093 								else // we want to reopen the browse path
       
  2094 									{
       
  2095 									browsePath->Back();
       
  2096 									iCollectionUtility->Collection().OpenL( *browsePath );
       
  2097 									}
       
  2098                                 CleanupStack::PopAndDestroy( pbPath );
  2097                                 CleanupStack::PopAndDestroy( pbPath );
  2099                                 }
  2098                                 }
  2100                             else
  2099                             else
  2101                                 {
  2100                                 {
  2102                                 // TO-DO: check if collection is empty, activate
  2101                                 // TO-DO: check if collection is empty, activate
  2103                                 // music main menu? or change ui spec
  2102                                 // music main menu? or change ui spec
  2104                                 AppUi()->HandleCommandL( EAknSoftkeyBack );
  2103                                 AppUi()->HandleCommandL( EAknSoftkeyBack );
  2105                                 }
  2104                                 }
  2106                             CleanupStack::PopAndDestroy( browsePath );
       
  2107                             CleanupStack::PopAndDestroy( playlist );
  2105                             CleanupStack::PopAndDestroy( playlist );
  2108                             }
  2106                             }
  2109                         else
  2107                         else
  2110                             {
  2108                             {
  2111                             AppUi()->HandleCommandL( EAknSoftkeyBack );
  2109                             AppUi()->HandleCommandL( EAknSoftkeyBack );
  2113                         }
  2111                         }
  2114                     else
  2112                     else
  2115                         {
  2113                         {
  2116                         CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
  2114                         CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
  2117                         CleanupStack::PushL( cpath );
  2115                         CleanupStack::PushL( cpath );
  2118                         while ( cpath->Levels() > 1 )
  2116                         while ( cpath->Levels() > 2 )
  2119                             {
  2117                             {
  2120                             cpath->Back();
  2118                             cpath->Back();
  2121                             }
  2119                             }
  2122                         iCollectionUtility->Collection().OpenL( *cpath );
  2120                         iCollectionUtility->Collection().OpenL( *cpath );
  2123                         CleanupStack::PopAndDestroy( cpath );
  2121                         CleanupStack::PopAndDestroy( cpath );
  2646         {
  2644         {
  2647         toolbar->HideItemsAndDrawOnlyBackground(ETrue);
  2645         toolbar->HideItemsAndDrawOnlyBackground(ETrue);
  2648         toolbar->SetToolbarVisibility(EFalse);
  2646         toolbar->SetToolbarVisibility(EFalse);
  2649         toolbar->MakeVisible(EFalse);
  2647         toolbar->MakeVisible(EFalse);
  2650         AppUi()->RemoveFromStack( toolbar );
  2648         AppUi()->RemoveFromStack( toolbar );
       
  2649         }
       
  2650     
       
  2651     if ( iTNRequestTimer->IsActive())
       
  2652         {
       
  2653         iTNRequestTimer->Cancel();
  2651         }
  2654         }
  2652     }
  2655     }
  2653 
  2656 
  2654 // ---------------------------------------------------------------------------
  2657 // ---------------------------------------------------------------------------
  2655 // From CAknView
  2658 // From CAknView
  2989 // Callback function when layout is changed.
  2992 // Callback function when layout is changed.
  2990 // ---------------------------------------------------------------------------
  2993 // ---------------------------------------------------------------------------
  2991 //
  2994 //
  2992 EXPORT_C void CMPXCommonPlaybackViewImp::HandleLayoutChange()
  2995 EXPORT_C void CMPXCommonPlaybackViewImp::HandleLayoutChange()
  2993     {
  2996     {
  2994     iContainer->ExtractAlbumArtCompleted( NULL, KErrNone );
       
  2995     if (iContainer && !iSwitchingView)
  2997     if (iContainer && !iSwitchingView)
  2996         {
  2998         {
  2997         if ( !Layout_Meta_Data::IsLandscapeOrientation() )
  2999         if ( !Layout_Meta_Data::IsLandscapeOrientation() )
  2998             {
  3000             {
  2999             TUid activeView = iViewUtility->ActiveViewImplementationUid();
  3001             TUid activeView = iViewUtility->ActiveViewImplementationUid();
  3998             }
  4000             }
  3999     	}
  4001     	}
  4000 
  4002 
  4001     return KErrNone;
  4003     return KErrNone;
  4002     }
  4004     }
       
  4005 
       
  4006 // ---------------------------------------------------------------------------
       
  4007 // Updates track's album art.
       
  4008 // ---------------------------------------------------------------------------
       
  4009 //
       
  4010 TInt CMPXCommonPlaybackViewImp::HandleTNRequestForCustomSizeL( TAny* aPtr )
       
  4011     {
       
  4012     MPX_DEBUG1("CMPXCommonPlaybackViewImp::HandleTNRequestForCustomSizeL()");
       
  4013     
       
  4014     ASSERT( aPtr );
       
  4015     CMPXCommonPlaybackViewImp* pv = reinterpret_cast<CMPXCommonPlaybackViewImp*>( aPtr );
       
  4016     
       
  4017     ASSERT( pv->iOldUri );   
       
  4018     if ( pv->iContainer && !pv->iSwitchingView )
       
  4019         {
       
  4020         TInt err( KErrNone );      
       
  4021         if ( pv->iMedia && pv->iMedia->IsSupported(KMPXMediaGeneralUri) )
       
  4022             {
       
  4023             const TDesC& album = pv->iMedia->ValueText( KMPXMediaGeneralUri );
       
  4024 
       
  4025             if ( pv->iOldUri->Compare( album ) == 0 )
       
  4026                 { 
       
  4027                 TRect albumArtRect(
       
  4028                         pv->iLayout->IndicatorLayout(
       
  4029                         pv->ClientRect(), EAlbumArtArea ) );
       
  4030                 
       
  4031                 // Request for custom TN size               
       
  4032                 MPX_TRAP( err,
       
  4033                     pv->iMPXUtility->ExtractAlbumArtL(
       
  4034                     *pv->iMedia,
       
  4035                     *pv->iContainer,
       
  4036                     albumArtRect.Size() ); );                
       
  4037                 }
       
  4038             }
       
  4039 
       
  4040         if ( KErrNone != err )
       
  4041             {
       
  4042             // If error, show default album art
       
  4043             MPX_DEBUG2("CMPXCommonPlaybackViewImp::HandleTNRequestForCustomSizeL(): err = %d", err);
       
  4044             pv->iContainer->ExtractAlbumArtCompleted( NULL, KErrNone );
       
  4045             }
       
  4046         }
       
  4047     
       
  4048     // cancel timer
       
  4049     if ( pv->iTNRequestTimer->IsActive())
       
  4050         {
       
  4051         pv->iTNRequestTimer->Cancel();
       
  4052         }
       
  4053         
       
  4054     return KErrNone;
       
  4055     }
       
  4056     
  4003 //  End of File
  4057 //  End of File