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

2011/5/23

Sound loop delay

SirFoxie SirFoxie

2011/5/23

#
I'm trying to play some music in my scenario by looping short MP3 files, but there's a big delay between each looped sound (like half a second). There is no delay in the actual file; I checked. Here's my code:
public class Music extends Actor
{
    private GreenfootSound bass;
    private GreenfootSound drums;
    
    public Music()
    {
        bass = new GreenfootSound("bass.mp3");
        drums = new GreenfootSound("drums.mp3");
    }
    
    public void act()
    {
        bass.playLoop();
        drums.playLoop();
    }
}
Any way to get it to loop with no delay? Thanks. :D
SirFoxie SirFoxie

2011/5/25

#
I think the problem is that sounds in Greenfoot are streamed each time you play them, rather than loaded fully into memory and read from there on each play. So they have to buffer on every play, which causes a delay between the time you tell a sound to play, and the time you actually hear it. I dunno how to fix that, though.
You need to login to post a reply.