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

2012/8/28

Problem with GreenfootSounds

Gevater_Tod4711 Gevater_Tod4711

2012/8/28

#
Hi all, I've got a problem with some GreenfootSounds: sometimes I get this exception: Exception in thread "SoundStream:file:/D:/Daten/Schule/Informatik/Java/Greenfoot-Szenarien/StarWars%20Szenarios/Star%20Wars%20Szenario%20V6.6/sounds/Mass%20Effect%203%20Soundtrack%20-%20The%20View%20of%20Palaven%20OST%20Music%205-2.mp3" java.lang.IllegalArgumentException: Could not open sound file: file:/D:/Daten/Schule/Informatik/Java/Greenfoot-Szenarien/StarWars%20Szenarios/Star%20Wars%20Szenario%20V6.6/sounds/Mass%20Effect%203%20Soundtrack%20-%20The%20View%20of%20Palaven%20OST%20Music%205-2.mp3 at greenfoot.sound.SoundExceptionHandler.handleIOException(SoundExceptionHandler.java:66) at greenfoot.sound.SoundStream.run(SoundStream.java:374) at java.lang.Thread.run(Thread.java:722) Caused by: java.io.IOException: javazoom.jl.decoder.BitstreamException: Bitstream errorcode 102 at greenfoot.sound.Mp3AudioInputStream.read(Mp3AudioInputStream.java:223) at greenfoot.sound.SoundStream.run(SoundStream.java:302) ... 1 more and I don't get why. The exeption is only thrown if I play soundfiles longer than about 1 minute. I already tryed to catch the exeption using this method:
public static void playMusic(int number) {
        switch (number) {
            case 1:
                try {
                    ImperialerMarsch.play();
                }
                catch (Exception e) {
                    ;
                }
                break;
            case 2:
                try {
                    MainTheme.play();
                }
                catch (Exception e) {
                    ;
                }
                break;
            case 3:
                try {
                    LevelMusic.play();
                }
                catch (Exception e) {
                    ;
                }
                break;
        }
    }
but I still got the exception. Doe's anybody know why I get the exception or better: How to stop it? Thanks for help
davmac davmac

2012/8/28

#
A corrupted MP3 file, or an MP3 that's not really an MP3 (the filename ends with .MP3 but it's in some other container format), possibly.
Gevater_Tod4711 Gevater_Tod4711

2012/8/28

#
Yes, all files are MP3. Would it help to convert them into other soundfiles (.wav or what ever)?
davmac davmac

2012/8/28

#
Well, the problem is they may be too big. You need MP3 files that are in the regular MP3 container format, it's difficult to explain but basically you can have a file that is named .MP3 but is in another container format, which the JLayer library can't handle. How did you get / create these MP3s?
Builderboy2005 Builderboy2005

2012/8/29

#
Some Mp3's also are created with addition information tacked onto the end of the file. Non sound information that is, and when the mp3 library tries to read it as sound it can give those errors you see. Unfortunately, I don't know of any specific way to get rid of this error without modifying the sound file using an audio editing program.
mjrb4 mjrb4

2012/8/29

#
One thing that worked for me when I got this error was opening the mp3 in audacity (free) and then re-encoding it. Time-consuming if you've got lots of sounds, but a quick solution if it's just one causing the issue.
Gevater_Tod4711 Gevater_Tod4711

2012/8/29

#
Ok thanks all. I'll try to use audacity (I already got the programm). I got the sounds from YouTube (free YouTube to MP3 converter). But what makes me suprise: sometimes the sounds work like I want them to, but also sometimes they don't. So I don't think that they are broken. But I don't know so much about Greenfoots SoundBuffers or what ever throws the Exception.
You need to login to post a reply.