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

2022/4/28

How To Import Music?

1
2
Karmatic Karmatic

2022/4/28

#
I keep trying to put music into my game, but it cannot process that for some reason I am using the code
 GreenfootSound backgroundMusic = new GreenfootSound("exampletext.mp3");
does it have to be .wav, or is there something I'm missing I have it in my project's sound folder but it says nothing is there
Karmatic Karmatic

2022/4/28

#
error code is java.lang.IllegalArgumentException: Could not open sound file: SHMC.mp3 at greenfoot.sound.SoundExceptionHandler.handleIOException(SoundExceptionHandler.java:66) at greenfoot.sound.SoundFactory.createSound(SoundFactory.java:120) at greenfoot.GreenfootSound.<init>(GreenfootSound.java:54) at MyWorld.<init>(MyWorld.java:11) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at greenfoot.core.Simulation.newInstance(Simulation.java:580) at greenfoot.platforms.ide.WorldHandlerDelegateIDE.lambda$instantiateNewWorld$0(WorldHandlerDelegateIDE.java:143) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:470) at greenfoot.core.Simulation.maybePause(Simulation.java:299) at greenfoot.core.Simulation.runContent(Simulation.java:190) at greenfoot.core.Simulation.run(Simulation.java:183) Caused by: java.io.FileNotFoundException: Could not find file: SHMC.mp3 at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:189) at greenfoot.sound.SoundFactory.createSound(SoundFactory.java:99) ... 12 more
Karmatic Karmatic

2022/5/1

#
desperately need help
Roshan123 Roshan123

2022/5/1

#
“exampletext.mp3” doesn't at all match with “SHMC.mp3” I guess its just an example to show how you wrote and I hope you took care of this following things: 1) The background music is in “sounds” folder only 2) The name and extension should be exactly the same in folder 3) uppercase and lowercase should also be the same
Karmatic Karmatic

2022/5/2

#
yes, that is what I did, but is still giving me errors
Roshan123 Roshan123

2022/5/2

#
Karmatic wrote...
yes, that is what I did, but is still giving me errors
What have you done? Their is tons of thing what I said. So to which one are you referring?
danpost danpost

2022/5/2

#
Karmatic wrote...
I am using the code
 GreenfootSound backgroundMusic = new GreenfootSound("exampletext.mp3");
First off, that line does not deal with file "SHMC.mp3", which the error message refers to. Secondly, there is no context given as to where the line is within the class. If you give the proper line of code, also include a description of where it is in the class or, better yet, supply the entire class code.
Karmatic Karmatic

2022/5/3

#
First, @Roshan123, I meant all three thing in the list. Second, @danpost, I know that "exampletext" and "SHMC" are different, thank you. I wanted to edit the first post after posting the error code but couldn't. And Third, Dan, it was in MyWorld, in the main block of code, under
 super (600, 400, 1); 
I also tried above the yellow box. What did I do wrong?
Karmatic Karmatic

2022/5/3

#
As in
 super (600, 400, 1)
GreenfootSound backgroundMusic = new GreenfootSound("SHMC.mp3");
Karmatic Karmatic

2022/5/3

#
Roshan123 wrote...
Karmatic wrote...
yes, that is what I did, but is still giving me errors
What have you done? Their is tons of thing what I said. So to which one are you referring?
*there
Roshan123 Roshan123

2022/5/3

#
I need the full script. Not sure about @danpost
Karmatic Karmatic

2022/5/3

#
Roshan123 wrote...
I need the full script. Not sure about @danpost
what do you mean by the "full script"?
Spock47 Spock47

2022/5/3

#
Karmatic wrote...
I have it in my project's sound folder but it says nothing is there
Just to be sure, since the computer is very strict about typos: You wrote "sound" (without s at the end). But the folder in your project is called "sounds" with an "s" at the end, right?
Roshan123 Roshan123

2022/5/4

#
Karmatic wrote...
what do you mean by the "full script"?
I mean code of every class which is dealing with the music
Karmatic Karmatic

2022/5/4

#
Spock47 wrote...
Karmatic wrote...
I have it in my project's sound folder but it says nothing is there
Just to be sure, since the computer is very strict about typos: You wrote "sound" (without s at the end). But the folder in your project is called "sounds" with an "s" at the end, right?
yes
There are more replies on the next page.
1
2