Skip to content Skip to sidebar Skip to footer

Android Mediaplayer Chopping In Background

I'm trying to implement a service to play a stream in background using mediaplayer class.. anyway in some phone (galaxy tab and some LG model) when my app is in background, the sou

Solution 1:

You need to manually stop and resume the audio which has been played in Media player using pause and resume Method of activity , take a look at this,

 @Override
protected void onResume() {
    super.onResume();
    if (mediaPlayer != null) {
        mediaPlayer.start();
    }
}

protected void onPause() {
    super.onPause();
    if (mediaPlayer != null) {
        mediaPlayer.pause();
        if (isFinishing()) {
            mediaPlayer.stop();
            mediaPlayer.release();
        }
    }

Post a Comment for "Android Mediaplayer Chopping In Background"