sound error :Uncaught exception java/lang/IllegalArgumentException.

If i run the game after adding the following code for adding sound I get the following error:

Starting emulator in execution mode

Running with storage root DefaultColorPhone

Uncaught exception java/lang/IllegalArgumentException.

Any ideas?

Thank you!!!!

import javax.microedition.media.*;

import javax.microedition.media.control.*;

........

private Player explosionSound;

...........

public void run() {

try {

InputStream is = getClass().getResourceAsStream("gameover.mid");

explosionSound= Manager.createPlayer(is,"udio/X-wav");

explosionSound.prefetch();

}

catch (IOException ioe) {

System.out.println(ioe.toString());

}

catch (MediaException me) {

System.out.println(me.toString());

}

}

while(running) {

//do stuff

if (bulletNave.collidesWith(alienSprite,false)) {

try {

explosionSound.start();

} catch (MediaException me) {

System.out.println(me.toString());

}

}

}

[1079 byte] By [mocasua] at [2007-11-27 2:09:44]
# 1
Hi, try this:explosionSound= Manager.createPlayer(is,"audio/x-wav");Hope that help, Jack
jack@square6a at 2007-7-12 2:00:33 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
Sorry, it was my mistake,I actually have:explosionSound= Manager.createPlayer(is,"audio/X-wav");I tried what you mention:explosionSound= Manager.createPlayer(is,"audio/x-wav");but I still have the error...
mocasua at 2007-7-12 2:00:33 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

Hi,

From the doc of createPlayer : IllegalArgumentException - Thrown if stream is null. Check your InputStream (file can be in a different

directory for example if your project as your sound file is in a

package "mypackage", getResourceAsStream must be called with

argument "/mypackage/gameover.mid").

Note: extension mid is usually for MIDI files, if it's the case, createPlayer

must be called with "audio/midi" argument.

Try this:

try

{

InputStream is = getClass().getResourceAsStream("/mypackage/gameover.mid");

if (is != null)

{

explosionSound= Manager.createPlayer(is,"audio/midi");

explosionSound.prefetch();

}

}

catch (IOException ioe)

{

System.out.println(ioe.toString());

}

catch (MediaException me)

{

System.out.println(me.toString());

}

Hope that help,

Jack

jack@square6a at 2007-7-12 2:00:33 > top of Java-index,Java Mobility Forums,Java ME Technologies...