musichomescreen_multiview/mcpmusicplayer/src/mcpmusicplayer.cpp
branchRCL_3
changeset 14 943ff5625028
parent 2 b70d77332e66
child 17 c8156a91d13c
equal deleted inserted replaced
11:13afc0e517bd 14:943ff5625028
   675     switch ( aState )
   675     switch ( aState )
   676             {
   676             {
   677             case EMPlayerStatePlaying:
   677             case EMPlayerStatePlaying:
   678                 {
   678                 {
   679                 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStatePlaying");
   679                 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStatePlaying");
       
   680                 iMusicPlayerOpeningTimer->Cancel();
   680                 UpdateToolBarL(TBK::KSkeep_L|TBK::KPause|TBK::KSkeep_R);
   681                 UpdateToolBarL(TBK::KSkeep_L|TBK::KPause|TBK::KSkeep_R);
   681                 break;
   682                 break;
   682                 }
   683                 }
   683             case EMPlayerStatePaused:
   684             case EMPlayerStatePaused:
   684                 {
   685                 {
   695                 break;
   696                 break;
   696                 }
   697                 }
   697             case EMPlayerStateStopped:
   698             case EMPlayerStateStopped:
   698                 {
   699                 {
   699                 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStateStopped");
   700                 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStateStopped");
   700                 if ( iUSBOnGoing )
   701                 if ( iBlockingOperationOngoing )
   701                     {
   702                     {
   702                     UpdateToolBarL( TBK::KSkeep_L_dimmed |
   703                     UpdateToolBarL( TBK::KSkeep_L_dimmed |
   703                             TBK::KPlay_dimmed |
   704                             TBK::KPlay_dimmed |
   704                             TBK::KSkeep_R_dimmed );
   705                             TBK::KSkeep_R_dimmed );
   705                     }
   706                     }
  1207     {
  1208     {
  1208     TInt event = aMsg.ValueTObjectL<TInt> ( KMPXMessageGeneralEvent );
  1209     TInt event = aMsg.ValueTObjectL<TInt> ( KMPXMessageGeneralEvent );
  1209     TInt type = aMsg.ValueTObjectL<TInt> ( KMPXMessageGeneralType );
  1210     TInt type = aMsg.ValueTObjectL<TInt> ( KMPXMessageGeneralType );
  1210     MPX_DEBUG3("--->CMCPMusicPlayer::DoHandleGeneralMessageL(), event = %d, type = %d", event, type);
  1211     MPX_DEBUG3("--->CMCPMusicPlayer::DoHandleGeneralMessageL(), event = %d, type = %d", event, type);
  1211 
  1212 
       
  1213     
  1212     if ( event == TMPXCollectionMessage::EBroadcastEvent
  1214     if ( event == TMPXCollectionMessage::EBroadcastEvent
  1213         && ( type == EMcMsgUSBMassStorageStart || type == EMcMsgUSBMTPStart ))
  1215         && ( type == EMcMsgUSBMassStorageStart || 
  1214         {
  1216              type == EMcMsgUSBMTPStart ||
  1215         iUSBOnGoing = ETrue;
  1217              type == EMcMsgRefreshStart ))
  1216         MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iUSBOnGoing changed to: %d", iUSBOnGoing );
  1218         {
       
  1219         iBlockingOperationOngoing = ETrue;
       
  1220         MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iBlockingOperationOngoing changed to: %d", 
       
  1221                   iBlockingOperationOngoing );
  1217         UpdateToolBarL( TBK::KSkeep_L_dimmed |
  1222         UpdateToolBarL( TBK::KSkeep_L_dimmed |
  1218                 TBK::KPlay_dimmed |
  1223                 TBK::KPlay_dimmed |
  1219                 TBK::KSkeep_R_dimmed );
  1224                 TBK::KSkeep_R_dimmed );
  1220         if ( IsOKToPublishData() )
  1225         if ( IsOKToPublishData() )
  1221             {
  1226             {
  1222             InstallGoToAlbumL(EMusicMenuMusicInfoTrigger);
  1227             InstallGoToAlbumL(EMusicMenuMusicInfoTrigger);
  1223             }
  1228             }
  1224         }
  1229         }
  1225     else if ( event == TMPXCollectionMessage::EBroadcastEvent
  1230     else if ( event == TMPXCollectionMessage::EBroadcastEvent
  1226             && ( type == EMcMsgUSBMassStorageEnd || type == EMcMsgUSBMTPEnd ))
  1231             && ( type == EMcMsgUSBMassStorageEnd || 
  1227         {
  1232                  type == EMcMsgUSBMTPEnd ||
  1228         iUSBOnGoing = EFalse;
  1233                  type == EMcMsgRefreshEnd ))
  1229         MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iUSBOnGoing changed to: %d", iUSBOnGoing );
  1234         {
       
  1235         iBlockingOperationOngoing = EFalse;
       
  1236         MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iBlockingOperationOngoing changed to: %d", 
       
  1237                    iBlockingOperationOngoing );
  1230         DoUpdatePlayerStateL( iEngine->PlayerState() );
  1238         DoUpdatePlayerStateL( iEngine->PlayerState() );
  1231         if ( IsOKToPublishData() )
  1239         if ( IsOKToPublishData() )
  1232             {
  1240             {
  1233             iMHObserver->PublishTextL( this, EMusicWidgetDefaultText,
  1241             iMHObserver->PublishTextL( this, EMusicWidgetDefaultText,
  1234                     KEmpty );
  1242                     KEmpty );
  1295 // Music Player opening timer callback
  1303 // Music Player opening timer callback
  1296 // ----------------------------------------------------------------------------
  1304 // ----------------------------------------------------------------------------
  1297 //
  1305 //
  1298 TInt CMCPMusicPlayer::MusicPlayerOpeningTimerCallback( TAny* aPtr )
  1306 TInt CMCPMusicPlayer::MusicPlayerOpeningTimerCallback( TAny* aPtr )
  1299     {
  1307     {
  1300     MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback <---");
  1308     MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback <---");     
  1301     RWsSession wsSession;
  1309     if ( EMPlayerStatePlaying != static_cast<CMCPMusicPlayer*>(aPtr)->iEngine->PlayerState() )
  1302     TInt error = wsSession.Connect();
  1310         {
  1303     if ( error != KErrNone )
  1311         MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback Music Player not Playing");
  1304         {
  1312         //Reset the widget and menu, music player is not running and playing.
  1305         return error;
  1313         static_cast<CMCPMusicPlayer*>(aPtr)->iActive = EFalse;
  1306         }
       
  1307     
       
  1308     TBool taskExists( EFalse );
       
  1309     CAknTaskList* taskList( NULL );
       
  1310     TRAPD( err, taskList = CAknTaskList::NewL( wsSession ) );
       
  1311     if ( err == KErrNone )
       
  1312         {
       
  1313         MPX_DEBUG2("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback "
       
  1314                 "error = %d occur when creating CAknTaskList", err);
       
  1315         TApaTask task = taskList->FindRootApp( TUid::Uid( KMusicPlayerAppUidAsTInt ) );
       
  1316         delete taskList;
       
  1317         taskExists = task.Exists();
       
  1318         }
       
  1319     wsSession.Close();
       
  1320     
       
  1321     if ( !taskExists )
       
  1322         {
       
  1323         MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback Music Player not opened");
       
  1324         //Reset the widget and menu, music player is not running
       
  1325         TRAP_IGNORE( static_cast<CMCPMusicPlayer*>(aPtr)->ResetL() );
  1314         TRAP_IGNORE( static_cast<CMCPMusicPlayer*>(aPtr)->ResetL() );
  1326         }
  1315         }
  1327     static_cast<CMCPMusicPlayer*>(aPtr)->iMusicPlayerOpeningTimer->Cancel();
  1316     static_cast<CMCPMusicPlayer*>(aPtr)->iMusicPlayerOpeningTimer->Cancel();
  1328     
  1317     
  1329     MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback --->");
  1318     MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback --->");