Problem with apwidgets

edited March 2014 in Android Mode

Hi, I've done a sketch which runs fine. It plays an mp3 file using the apwidgets library, all fine. The problem is that if I press the home button, it goes to the home screen but keeps playing the mp3... Is there a way to pause the mp3 ? Do I have to detect the home button pressing and do a player.pause() ?

Answers

  • Answer ✓

    I don't know APWidgets all that well, but it is certainly possible to detect a home button press. Even better, you can detect any time when your sketch is closed. Append this to your sketch:

    //Override Activity's onCreate()
    @ Override
    public void onStop() {
      //Pause the MP3 playback
      player.pause();
    
      //Do anything else that you need here...
    
      //Make sure to pass on to the parent
      super.onStop();
    }
    
  • Thank you very much Calsign ! I realized it wasn't a problem with apwidgets but with the behaviour of the sketch itself when pausing. Your solution solved all my problems.

Sign In or Register to comment.