1


I have a problem with the MediaPlayer.
I have a MediaPlayer class that starts as soon as the user launches the App, but as soon as the user taps on the "credits" button another activity starts with the credits screen, but the MediaPlayer stops playing the audio stream.

Is there a way to avoid this?

MediaPlayer setup:

player = new MediaPlayer();
player.prepareAsync();
player.setOnPreparedListener(new OnPreparedListener() {

    public void onPrepared(MediaPlayer mp) {
        player.start();
    }
});

I change page with this:

Intent intent = new Intent(this, Credits.class);
startActivity(intent);
Jonik
  • 80,077
  • 70
  • 264
  • 372
Roberto
  • 528
  • 7
  • 15
  • 1
    So, are you aiming to play background audio across all your activities? Does e.g. this question help? http://stackoverflow.com/questions/2097909/playing-bg-music-across-activities-in-android – Jonik Nov 25 '13 at 20:09

2 Answers2

1

Create a local service and put the MediaPlayer in that Service. Bind to the Service from whatever Activity needs to control the MediaPlayer.

Dave
  • 4,282
  • 2
  • 19
  • 24
0

This is not possible since the mediaActivity will be pause. You might consider using a dialog instead of an intent for the credits.

Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116