Hello, I am in the middle of creating an application that plays a
happy sound when you get a question right, and a bad sound when you
get a question wrong.  Needless to say this is a quiz application.

Now, if I create 2 objects (MEDIAPLAYER) like so:

MediaPlayer mp_e = MediaPlayer.create(this, R.raw.good);
MediaPlayer mp_e = MediaPlayer.create(this, R.raw.bad);

at the beginning of the application (before my onCreate() where I
declare/instantiate all other variables) I get a "Force Close."

If i create the objects in the "if answer is right (play good sound),
else is wrong (play bad sound)," I get a force close after about 7
questions or so into the quiz. ?

Here is the syntax I used:

if (correct) {
MediaPlayer mp_f = MediaPlayer.create(this, R.raw.good);
mp_f.start();
...
next question
}
else {
MediaPlayer mp_f = MediaPlayer.create(this, R.raw.bad);
mp_f.start();
...
next question
}

This works up until about question 7 on my AVD device (2.1-update1)
and question 8 on my Motorola Cliq.
I ran the "debugger" in Eclipse but I don't see anything useful at
all.  It looks like Android is breaking and not my code?

If i remove all sound objects and forgo the sound, the application
runs like a dream.
I realize that I can do "release();" after playing the sound, from a
tutorial I read, but that makes the sound not play at all.  I read
that you need to "reset and prepare" the mp_f MediaPlayer object, but
that doesn't help either.

Should I be threading these? the sounds are only like 1 maybe 2
seconds long and never overlap though.  How come it force closes after
7? what changes? all of my loop logical concepts stay exactly the same
as they did from 1 ~ 6, and if I remove the MediaPlayer objects it
works fine.

I have read everything I can on the subject from the Android Developer
site and from scraping forums.
help?  Thanks!

~Douglas.

-- 
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

Reply via email to