This site requires JavaScript, please enable it in your browser!
Greenfoot back
massivassl
massivassl wrote ...

2017/12/18

Sound problem

massivassl massivassl

2017/12/18

#
I've been trying to figure out what exactly is the problem here class Player1 is supposed to play the wilhelm scream sound effect when hit by Player2Bullet.
1
2
3
4
5
6
7
8
public void die()
   {
       if (canSee (Player2Bullet.class))
       {
           eat (Player2Bullet.class);
           getWorld().removeObject(this);
           Greenfoot.playSound ("wilhelm.wav");
       }
the programs returns an error popup when Player2Bullet hits Player1, saying that the sound file cannot be found. I checked, and wilhelm.wav is in the appropriate sounds folder.
massivassl massivassl

2017/12/18

#
this is what the error popup displays java.lang.IllegalArgumentException: Could not open sound file: wilhelm.wav at greenfoot.sound.SoundExceptionHandler.handleIOException(SoundExceptionHandler.java:67) at greenfoot.sound.SoundFactory.createSound(SoundFactory.java:120) at greenfoot.Greenfoot.playSound(Greenfoot.java:163) at Player1.die(Player1.java:64) at Player1.act(Player1.java:20) at greenfoot.core.Simulation.actActor(Simulation.java:604) at greenfoot.core.Simulation.runOneLoop(Simulation.java:562) at greenfoot.core.Simulation.runContent(Simulation.java:221) at greenfoot.core.Simulation.run(Simulation.java:211) Caused by: java.io.FileNotFoundException: Could not find file: wilhelm.wav at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:554) at greenfoot.sound.SoundFactory.createSound(SoundFactory.java:99) ... 7 more
danpost danpost

2017/12/18

#
Double check and make sure that none of the characters in the name of the sound file are uppercase (maybe its "Wilhelm.wav").
massivassl massivassl

2017/12/18

#
I checked as you suggested. the filename really is just wilhelm.wav, and that is exactly what i'm calling in the code, yet i keep getting the same error over and over again
danpost danpost

2017/12/18

#
Are you sure the 'sounds' file you put it in is in the currently active project folder (that you did not put it in a copied project folder)?
massivassl massivassl

2017/12/18

#
ah that was it. the sounds folder had a copy in the desktop. the scream was saved into that one. thanks
You need to login to post a reply.