javauis/mmapi_qt/baseline/src/cmmavolumecontrol.cpp
changeset 26 dc7c549001d5
parent 23 98ccebc37403
equal deleted inserted replaced
23:98ccebc37403 26:dc7c549001d5
    87     iLevel = aLevel;
    87     iLevel = aLevel;
    88 }
    88 }
    89 
    89 
    90 void CMMAVolumeControl::StateChanged(TInt aState)
    90 void CMMAVolumeControl::StateChanged(TInt aState)
    91 {
    91 {
    92     LOG1( EJavaMMAPI, EInfo, "CMMAVolumeControl::StateChanged - state %d", aState);
    92     LOG1(EJavaMMAPI, EInfo, "CMMAVolumeControl::StateChanged - state %d", aState);
    93     // Set the volume if the player is prefetched
    93     // Set the volume if the player is prefetched
    94     if (aState == CMMAPlayer::EPrefetched)
    94     if (aState == CMMAPlayer::EPrefetched)
    95     {
    95     {
    96         TRAPD(error,
    96         TRAPD(error,
    97         {
    97         {
   117     // Error ID AKUR-7G69Q5 GLOBAL VOLUME EVENT CR
   117     // Error ID AKUR-7G69Q5 GLOBAL VOLUME EVENT CR
   118     if (aState == CMMAPlayer::ERealized)
   118     if (aState == CMMAPlayer::ERealized)
   119     {
   119     {
   120         if ((iLevels.Count() - 1) == KMMAGlobalVolumeSoundIndex)
   120         if ((iLevels.Count() - 1) == KMMAGlobalVolumeSoundIndex)
   121         {
   121         {
   122             LOG( EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::StateChanged : Post GLOBAL VOL EVENT  ");
   122             LOG(EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::StateChanged : Post GLOBAL VOL EVENT  ");
   123             if (iLevels[ KMMAGlobalVolumeSoundIndex ] != KErrNotFound)
   123             if (iLevels[ KMMAGlobalVolumeSoundIndex ] != KErrNotFound)
   124             {
   124             {
   125                 LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::StateChanged : Post complete Val = %d ",iLevels[ KMMAGlobalVolumeSoundIndex ]);
   125                 LOG1(EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::StateChanged : Post complete Val = %d ",iLevels[ KMMAGlobalVolumeSoundIndex ]);
   126                 iPlayer->PostLongEvent(CMMAPlayerEvent::ENOKIA_EXTERNAL_VOLUME_EVENT,
   126                 iPlayer->PostLongEvent(CMMAPlayerEvent::ENOKIA_EXTERNAL_VOLUME_EVENT,
   127                                        iLevels[ KMMAGlobalVolumeSoundIndex ]);
   127                                        iLevels[ KMMAGlobalVolumeSoundIndex ]);
   128             }
   128             }
   129         }
   129         }
   130     }
   130     }
   131 }
   131 }
   132 
   132 
   133 void CMMAVolumeControl::RefreshVolume()
   133 void CMMAVolumeControl::RefreshVolume()
   134 {
   134 {
   135     LOG( EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::RefreshVolume ++ ");
   135     LOG(EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::RefreshVolume ++ ");
   136     TRAPD(error,
   136     TRAPD(error,
   137     {
   137     {
   138         // Get the default value for the Java sound level
   138         // Get the default value for the Java sound level
   139         if (iLevels[ KMMAJavaSoundIndex ] == KErrNotFound)
   139         if (iLevels[ KMMAJavaSoundIndex ] == KErrNotFound)
   140         {
   140         {
   148     if (error != KErrNone)
   148     if (error != KErrNone)
   149     {
   149     {
   150         iPlayer->PostStringEvent(CMMAPlayerEvent::EError,
   150         iPlayer->PostStringEvent(CMMAPlayerEvent::EError,
   151                                  KMMAVolumeErrorMsg);
   151                                  KMMAVolumeErrorMsg);
   152     }
   152     }
   153     LOG( EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::RefreshVolume -- ");
   153     LOG(EJavaMMAPI, EInfo, "MMA::CMMAVolumeControl::RefreshVolume -- ");
   154 }
   154 }
   155 
   155 
   156 void CMMAVolumeControl::RefreshControl()
   156 void CMMAVolumeControl::RefreshControl()
   157 {
   157 {
   158     RefreshVolume();
   158     RefreshVolume();
   167 }
   167 }
   168 
   168 
   169 EXPORT_C void CMMAVolumeControl::SetVolumeLevelL(TInt aLevelIndex,
   169 EXPORT_C void CMMAVolumeControl::SetVolumeLevelL(TInt aLevelIndex,
   170         TInt aVolumeLevel)
   170         TInt aVolumeLevel)
   171 {
   171 {
   172     LOG2( EJavaMMAPI, EInfo, "CMMAVolumeControl::SetVolumeLevelL - setting index %d, level %d",
   172     LOG2(EJavaMMAPI, EInfo, "CMMAVolumeControl::SetVolumeLevelL - setting index %d, level %d",
   173                aLevelIndex, aVolumeLevel);
   173          aLevelIndex, aVolumeLevel);
   174     if (0 >= iLevels.Count() ||  iLevels.Count() > 3)
   174     if (0 >= iLevels.Count() ||  iLevels.Count() > 3)
   175     {
   175     {
   176         return ;
   176         return ;
   177     }
   177     }
   178     TInt oldVolumeLevel = iLevels[ aLevelIndex ];
   178     TInt oldVolumeLevel = iLevels[ aLevelIndex ];
   199 }
   199 }
   200 
   200 
   201 void CMMAVolumeControl::GetVolumeLevelL(TInt aLevelIndex,
   201 void CMMAVolumeControl::GetVolumeLevelL(TInt aLevelIndex,
   202                                         TInt* aVolumeLevel)
   202                                         TInt* aVolumeLevel)
   203 {
   203 {
   204     LOG1( EJavaMMAPI, EInfo, "CMMAVolumeControl::GetVolumeLevelL - level index %d", aLevelIndex);
   204     LOG1(EJavaMMAPI, EInfo, "CMMAVolumeControl::GetVolumeLevelL - level index %d", aLevelIndex);
   205 
   205 
   206     // Return max volume if the default Java volume level is not yet known
   206     // Return max volume if the default Java volume level is not yet known
   207     if (aLevelIndex == KMMAJavaSoundIndex &&
   207     if (aLevelIndex == KMMAJavaSoundIndex &&
   208             iLevels[ KMMAJavaSoundIndex ] == KErrNotFound)
   208             iLevels[ KMMAJavaSoundIndex ] == KErrNotFound)
   209     {
   209     {
   211         return;
   211         return;
   212     }
   212     }
   213 
   213 
   214     *aVolumeLevel = iLevels[ aLevelIndex ];
   214     *aVolumeLevel = iLevels[ aLevelIndex ];
   215 
   215 
   216     LOG1( EJavaMMAPI, EInfo, "CMMAVolumeControl::GetVolumeLevelL - level %d", *aVolumeLevel);
   216     LOG1(EJavaMMAPI, EInfo, "CMMAVolumeControl::GetVolumeLevelL - level %d", *aVolumeLevel);
   217 }
   217 }
   218 
   218 
   219 TInt CMMAVolumeControl::CalculateLevel()
   219 TInt CMMAVolumeControl::CalculateLevel()
   220 {
   220 {
   221     TInt levelCount = iLevels.Count();
   221     TInt levelCount = iLevels.Count();