browserplugins/browseraudiovideoplugin/src/BavpPlugin.cpp
branchRCL_3
changeset 34 5dedbccec665
parent 33 dbd79466b1ed
child 35 5c11946e75b3
equal deleted inserted replaced
33:dbd79466b1ed 34:5dedbccec665
    42 // might leave.
    42 // might leave.
    43 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    44 CBavpPlugin::CBavpPlugin()
    44 CBavpPlugin::CBavpPlugin()
    45     : iError( EFalse ),
    45     : iError( EFalse ),
    46     iMimeType( NULL ), 
    46     iMimeType( NULL ), 
    47     iPauseState ( EFalse )
    47     iPauseState ( EFalse ), 
       
    48     iIsForeGround ( ETrue ), 
       
    49     iPauseInBackground (EFalse)
    48     {
    50     {
    49     
    51     
    50     }
    52     }
    51 
    53 
    52 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
   331 // can happen when other component takes top of CCoeControl stack, such as the 
   333 // can happen when other component takes top of CCoeControl stack, such as the 
   332 // Option Menu, another application, Screen saver, ... 
   334 // Option Menu, another application, Screen saver, ... 
   333 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   334 TInt CBavpPlugin::NotifyL( TNotificationType aCallType, void* aParam )
   336 TInt CBavpPlugin::NotifyL( TNotificationType aCallType, void* aParam )
   335     {
   337     {
       
   338     if(iBavpController)
       
   339         { 
       
   340         //if player is paused due to focus change or Visual history back and manually pressed Play, then we need 
       
   341         //to clear the pause state. 
       
   342         if(EBavpPlaying == iBavpController->State() && iPauseState)
       
   343             { 
       
   344             iPauseState = EFalse; 
       
   345             }
       
   346         }
       
   347     
   336     switch ( aCallType )
   348     switch ( aCallType )
   337         {
   349         {
   338         case EApplicationFocusChanged:
   350         case EApplicationFocusChanged:
   339             // The browser has gone in-focus (foreground), or out-focus
   351             // The browser has gone in-focus (foreground), or out-focus
   340             // (background), i.e. the browser is not on top of CCoeControl stack,
   352             // (background), i.e. the browser is not on top of CCoeControl stack,
   343                 {
   355                 {
   344                 // If Browser out-focus, we send this plugin aParam=EFalse.
   356                 // If Browser out-focus, we send this plugin aParam=EFalse.
   345                 // If Browser in-focus, we send this plugin aParam=ETrue, if
   357                 // If Browser in-focus, we send this plugin aParam=ETrue, if
   346                 // the plugin is (was) in-focus or activated.
   358                 // the plugin is (was) in-focus or activated.
   347                 iBavpController->HandleBrowserNotification( TBool(aParam) );
   359                 iBavpController->HandleBrowserNotification( TBool(aParam) );
   348  				if(!aParam) //app background
   360  					if(!aParam) //app background
   349                     {
   361                     {
       
   362                     iIsForeGround = EFalse; 
   350                     if(EBavpPlaying == iBavpController->State()) 
   363                     if(EBavpPlaying == iBavpController->State()) 
   351                         { 
   364                         { 
   352                         iPauseState = ETrue; 
   365                         iPauseState = ETrue; 
   353                         iBavpController->PauseL(); 
   366                         iPauseInBackground = ETrue; 
       
   367                         iBavpController->PauseL();
   354                         }
   368                         }
   355                     }
   369                     }
   356                 else    //app foreground  
   370                 else    //app foreground  
   357                     { 
   371                     { 
   358                     if(EBavpPaused == iBavpController->State() && iPauseState) 
   372                     iIsForeGround = ETrue;
       
   373                     if(EBavpPaused == iBavpController->State() && iPauseInBackground) 
   359                        { 
   374                        { 
   360                        iPauseState = EFalse; 
   375                        iPauseState = EFalse; 
       
   376                        iPauseInBackground = EFalse;
   361                        iBavpController->PlayL();
   377                        iBavpController->PlayL();
   362                        }
   378                        }
   363                     
   379                     
   364                     }
   380                     }
   365                 
   381                 
   367             break;
   383             break;
   368 
   384 
   369         case EPluginPause :
   385         case EPluginPause :
   370             if( !aParam )
   386             if( !aParam )
   371                {
   387                {
   372                 if(iBavpController  && iPauseState && (iBavpController->State() == EBavpPaused))
   388                 if(iBavpController  && iPauseState && (iBavpController->State() == EBavpPaused) && (iIsForeGround))
   373                     { 
   389                     { 
   374                     iPauseState = EFalse; 
   390                     iPauseState = EFalse; 
   375                     iBavpController->PlayL(); 
   391                     iBavpController->PlayL(); 
   376                     }
   392                     }
   377                } 
   393                }