photosgallery/slideshow/engine/controlsrc/shwmusiccontrol.cpp
branchRCL_3
changeset 18 78ad99c24f08
parent 17 a60acebbbd9d
equal deleted inserted replaced
17:a60acebbbd9d 18:78ad99c24f08
    55 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    56 CShwMusicControl* CShwMusicControl::NewL(
    56 CShwMusicControl* CShwMusicControl::NewL(
    57     MShwMusicObserver& aMusicObsvr, const TDesC& aFilePath )
    57     MShwMusicObserver& aMusicObsvr, const TDesC& aFilePath )
    58     {
    58     {
    59     TRACER(" CShwMusicControl::NewL");
    59     TRACER(" CShwMusicControl::NewL");
    60     GLX_LOG_INFO( "CShwMusicControl::NewL" );
       
    61     CShwMusicControl* self = 
    60     CShwMusicControl* self = 
    62         new( ELeave ) CShwMusicControl( aMusicObsvr, aFilePath );
    61         new( ELeave ) CShwMusicControl( aMusicObsvr, aFilePath );
    63     CleanupStack::PushL( self );
    62     CleanupStack::PushL( self );
    64     self->ConstructL();
    63     self->ConstructL();
    65     CleanupStack::Pop( self );
    64     CleanupStack::Pop( self );
    70 // Destructor.
    69 // Destructor.
    71 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    72 CShwMusicControl::~CShwMusicControl()
    71 CShwMusicControl::~CShwMusicControl()
    73     {
    72     {
    74     TRACER(" CShwMusicControl::~CShwMusicControl");
    73     TRACER(" CShwMusicControl::~CShwMusicControl");
    75     GLX_LOG_INFO( "CShwMusicControl::~CShwMusicControl" );
       
    76     if( iPlaybackUtility )
    74     if( iPlaybackUtility )
    77         {
    75         {
    78         //The Code Scanner Error is not corrected here in the case of
    76         //The Code Scanner Error is not corrected here in the case of
    79         //calling a leaving function in the Non Leaving Function
    77         //calling a leaving function in the Non Leaving Function
    80         //We need to write a seperate Function for this.
    78         //We need to write a seperate Function for this.
    94 // ConstructL.
    92 // ConstructL.
    95 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    96 void CShwMusicControl::ConstructL()
    94 void CShwMusicControl::ConstructL()
    97     {
    95     {
    98     TRACER("CShwMusicControl::ConstructL");
    96     TRACER("CShwMusicControl::ConstructL");
    99     GLX_LOG_INFO("CShwMusicControl::ConstructL");
       
   100     // need to specify the mode and observer, without these we get a crash
    97     // need to specify the mode and observer, without these we get a crash
   101     iPlaybackUtility = MMPXPlaybackUtility::NewL( KPbModeNewPlayer, this );
    98     iPlaybackUtility = MMPXPlaybackUtility::NewL( KPbModeNewPlayer, this );
   102     // music playback is sacrificed if MPX fails
    99     // music playback is sacrificed if MPX fails
   103     TRAPD( err, InitPlayerL() );
   100     TRAPD( err, InitPlayerL() );
   104     if( err == KErrNone )
   101     if( err == KErrNone )
   111 // Initialize the player with File Path
   108 // Initialize the player with File Path
   112 // ---------------------------------------------------------------------------
   109 // ---------------------------------------------------------------------------
   113 void CShwMusicControl::InitPlayerL()
   110 void CShwMusicControl::InitPlayerL()
   114     {
   111     {
   115     TRACER("CShwMusicControl::InitPlayerL");
   112     TRACER("CShwMusicControl::InitPlayerL");
   116     GLX_LOG_INFO( "CShwMusicControl::InitPlayerL" );
       
   117     RFs fs;
   113     RFs fs;
   118     User::LeaveIfError( fs.Connect() );
   114     User::LeaveIfError( fs.Connect() );
   119     CleanupClosePushL( fs );
   115     CleanupClosePushL( fs );
   120     User::LeaveIfError( fs.ShareProtected() );
   116     User::LeaveIfError( fs.ShareProtected() );
   121     RFile file;
   117     RFile file;
   148 // Retrieve the volume values
   144 // Retrieve the volume values
   149 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   150 void CShwMusicControl::VolumeL()
   146 void CShwMusicControl::VolumeL()
   151     {
   147     {
   152     TRACER("CShwMusicControl::VolumeL");
   148     TRACER("CShwMusicControl::VolumeL");
   153     GLX_LOG_INFO( "CShwMusicControl::VolumeL" );
       
   154     // Retrieve the volume - Volume indicator is shown upon slideshow start and
   149     // Retrieve the volume - Volume indicator is shown upon slideshow start and
   155     // when the volume is changed
   150     // when the volume is changed
   156     if (iMaxVolume == KErrNotFound)
   151     if (iMaxVolume == KErrNotFound)
   157         {
   152         {
   158         iPlaybackUtility->ValueL( *this, EPbPropertyMaxVolume );	
   153         iPlaybackUtility->ValueL( *this, EPbPropertyMaxVolume );	
   159         }
   154         }
   160     iPlaybackUtility->ValueL( *this, EPbPropertyVolume );
   155     iPlaybackUtility->ValueL( *this, EPbPropertyVolume );
       
   156     iPlaybackUtility->ValueL( *this, EPbPropertyMute );
   161     }
   157     }
   162 
   158 
   163 // -----------------------------------------------------------------------------
   159 // -----------------------------------------------------------------------------
   164 // NotifyL.
   160 // NotifyL.
   165 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   166 void CShwMusicControl::NotifyL( MShwEvent* aEvent )
   162 void CShwMusicControl::NotifyL( MShwEvent* aEvent )
   167     {
   163     {
   168     TRACER("CShwMusicControl::NotifyL");
   164     TRACER("CShwMusicControl::NotifyL");
   169     GLX_LOG_INFO( "CShwMusicControl::NotifyL" );
       
   170     // only handle events if music initialisation succeeded
   165     // only handle events if music initialisation succeeded
   171     if( iState == EMusicOn )
   166     if( iState == EMusicOn )
   172         {
   167         {
   173         // reset state flag
   168         // reset state flag
   174         iSwitchingMusicOn = EFalse;
   169         iSwitchingMusicOn = EFalse;
   191 void CShwMusicControl::HandlePropertyL( TMPXPlaybackProperty aProperty,
   186 void CShwMusicControl::HandlePropertyL( TMPXPlaybackProperty aProperty,
   192                                         TInt aValue,
   187                                         TInt aValue,
   193                                         TInt aError )
   188                                         TInt aError )
   194     {
   189     {
   195     TRACER("CShwMusicControl::HandlePropertyL");
   190     TRACER("CShwMusicControl::HandlePropertyL");
   196     GLX_LOG_INFO( "CShwMusicControl::HandlePropertyL" );
       
   197 
   191 
   198     // leave if there was an error
   192     // leave if there was an error
   199     User::LeaveIfError( aError );
   193     User::LeaveIfError( aError );
   200 
   194 
   201     // handle max volume and volume, ignore other properties
   195     // handle max volume and volume, ignore other properties
   202     if( EPbPropertyMaxVolume == aProperty )
   196     if( EPbPropertyMaxVolume == aProperty )
   203         {
   197         {
       
   198         GLX_LOG_INFO("EPbPropertyMaxVolume = aProperty");
   204         iMaxVolume = aValue;
   199         iMaxVolume = aValue;
   205         }
   200         }
   206     else if( EPbPropertyVolume == aProperty )
   201     else if( EPbPropertyVolume == aProperty )
   207         {
   202         {
       
   203         GLX_LOG_INFO1("EPbPropertyVolume = aProperty - aValue: %d",aValue);
   208         // set the current volume
   204         // set the current volume
   209         iCurrentVolume = aValue;
   205         iCurrentVolume = aValue;
   210         // call observer only when max volume is also known
   206         // call observer only when max volume is also known
   211         // iMaxVolume and iCurrentVolume are initialized to KErrNotFound
   207         // iMaxVolume and iCurrentVolume are initialized to KErrNotFound
   212         if( iMaxVolume != KErrNotFound )
   208         if( iMaxVolume != KErrNotFound )
   213         	{
   209         	{
   214         	iMusicObsvr.MusicVolumeL( iCurrentVolume, iMaxVolume );
   210         	iMusicObsvr.MusicVolumeL( iCurrentVolume, iMaxVolume );
   215         	}
   211         	}
   216         }
   212         }
       
   213     else if( EPbPropertyMute == aProperty)
       
   214         {
       
   215         GLX_LOG_INFO1("EPbPropertyMute = aProperty - aValue: %d",aValue);
       
   216         //Ref: TMPXPlaybackProperty - EPbPropertyMute - aValue 0(normal), 1(muted)
       
   217         if(aValue == 1)
       
   218             {
       
   219             iCurrentVolume = 0;
       
   220             if( iMaxVolume != KErrNotFound )
       
   221                 {                
       
   222                 iMusicObsvr.MusicVolumeL( iCurrentVolume, iMaxVolume );
       
   223                 }
       
   224             }
       
   225         }
   217     }
   226     }
   218 
   227 
   219 // -----------------------------------------------------------------------------
   228 // -----------------------------------------------------------------------------
   220 // From MMPXPlaybackCallback
   229 // From MMPXPlaybackCallback
   221 // Method is called continously until aComplete=ETrue, signifying that 
   230 // Method is called continously until aComplete=ETrue, signifying that 
   263 // From MMPXPlaybackObserver
   272 // From MMPXPlaybackObserver
   264 // ---------------------------------------------------------------------------
   273 // ---------------------------------------------------------------------------
   265 void CShwMusicControl::HandlePlaybackMessage(const CMPXMessage& aMsg)
   274 void CShwMusicControl::HandlePlaybackMessage(const CMPXMessage& aMsg)
   266     {
   275     {
   267     TRACER("CShwMusicControl::HandlePlaybackMessage");
   276     TRACER("CShwMusicControl::HandlePlaybackMessage");
   268     GLX_LOG_ENTRY_EXIT( "CShwMusicControl::HandlePlaybackMessageL()" );
       
   269     
   277     
   270     switch(*aMsg.Value<TMPXPlaybackMessage::TEvent>( KMPXMessageGeneralEvent ))
   278     switch(*aMsg.Value<TMPXPlaybackMessage::TEvent>( KMPXMessageGeneralEvent ))
   271         {
   279         {
   272         case TMPXPlaybackMessage::EInitializeComplete:
   280         case TMPXPlaybackMessage::EInitializeComplete:
   273                 {
   281                 {
   305 // HandleEventL.
   313 // HandleEventL.
   306 // -----------------------------------------------------------------------------
   314 // -----------------------------------------------------------------------------
   307 void CShwMusicControl::HandleEventL( MShwEvent* aEvent )
   315 void CShwMusicControl::HandleEventL( MShwEvent* aEvent )
   308     {
   316     {
   309     TRACER("CShwMusicControl::HandleEventL( MShwEvent* aEvent )");
   317     TRACER("CShwMusicControl::HandleEventL( MShwEvent* aEvent )");
   310     GLX_LOG_INFO( "CShwTimerControl::HandleEventL" );
       
   311     // we got an event, was it start
   318     // we got an event, was it start
   312     if( dynamic_cast< TShwEventStart* >( aEvent ) )
   319     if( dynamic_cast< TShwEventStart* >( aEvent ) )
   313         {
   320         {
   314         GLX_LOG_INFO( "CShwMusicControl::NotifyL - TShwEventStart" );
   321         GLX_LOG_INFO( "CShwMusicControl::NotifyL - TShwEventStart" );
   315         // set state flag
   322         // set state flag