In Motorola XOOM view.startAnimation causes MediaPlayer to stop

My code to launch the media player:

MediaPlayer player = MediaPlayer.create(context, Uri.fromFile(new File(context.getExternalCacheDir().getAbsolutePath()+ File.separator + "test.mp3")));//MediaPlayer.create(context, resId);
    player.setAudioStreamType(playOnStream);
    player.start();
    player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            mp.release();
        }
    });

if after that I start any animation (I have different animations with different views start one after another, listening to onAnimationEnd) mediaplayer stops with a logcat message:

05-08 11:17:43.180: W/MediaPlayer-JNI(6571): MediaPlayer finalized without being released

I currently have no ideas on how to work around this

+3
source share
1 answer

Be sure to release the media player object in onPause()and prepare it again inonResume()

0
source

All Articles