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

2012/5/22

Reliably playing sound in Greenfoot

triss triss

2012/5/22

#
Hi all, I'm having issues getting Greenfoot to reliably play back sounds. The timing is incredibly wonky and sometimes sounds don't trigger at all. I've attempted to use GreenfootSound class and also the method described here: http://stackoverflow.com/questions/5291725/java-sound-api-initialization everytime i call .open a LineUnavailiableException is thrown. Is greenfoot already using the Line returned by Audiosystem? Can anyone recommend a reliable solution? I'm on OS X 10.6.8.
kartikitrak kartikitrak

2012/5/22

#
TIPS: Shorten the sound click as short as possible without messing with the overall sound of sound.
        if (nameOfSound.isPlaying())
        {
            nameOfSound.stop();
        }
        else
        {
            nameOfSound.play();
        }
matt.milan matt.milan

2012/5/22

#
Greenfoot version of initialize sounds
public class example
    {
    private GreenfootSound nameOfSound = new GreenfootSound"nameOfSound.mp3";
    
    public void someMethod()
    {
        if (eventOccurs()) nameOfSound.play();
}

}
davmac davmac

2012/5/22

#
triss: Greenfoot version?
Builderboy2005 Builderboy2005

2012/5/22

#
I think another question would be to ask what Java version are you running? I know that Java version less than Java 7 have horrible issues with sound. I myself was having issues with sound until I updated, and I have had no issues since.
davmac davmac

2012/5/22

#
On Mac OS X, the Java version is essentially fixed - it's updated along with other OS components, so it's generally difficult to get into a situation where you have a really old Java version; in any case, though previous Java-for-mac versions have had "issues" with sound, they've generally not had the problems described above. (Also, Java 7 isn't available for OS X 10.6).
You need to login to post a reply.