Hi! This is my first post to the list. I'm working on a kids' game
that plays some small wav files in a predictable order. I need to use
an OnCompletionListener to know when to start the next sound, but I
also need to avoid multiple MediaPlayers using all my memory. Could
someone suggest a smart way to do this? I have tested the following
code snippet, and while it functions well, it does crash eventually.
Why does mp = MediaPlayer.create() not overwrite the previous mp
object/free the memory used previously, and how can I fix that?
Eclipse won't let me use mp.recycle().
// That's right!
mp = MediaPlayer.create(mContext, R.raw.thats_right);
mp.setOnCompletionListener(new OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer arg0) {
// a horse
mp = MediaPlayer.create(mContext, rightAnswer.getName());
mp.setOnCompletionListener(new OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer mp) {
// says
mp = MediaPlayer.create(mContext, R.raw.says);
mp.setOnCompletionListener(new
OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer
mp) {
// neeeeeiggggghhhhhhh
mp =
MediaPlayer.create(mContext, rightAnswer.getSound());
mp.setOnCompletionListener(new
OnCompletionListener(){
@Override
public void
onCompletion(MediaPlayer mp) {
// start all
over
}
});
mp.start();
}
});
mp.start();
}
});
mp.start();
}
});
mp.start();
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en