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

2015/3/26

Problem with sound, play() doesnt wait for sound to finish to start again.

ziLaK ziLaK

2015/3/26

#
In my game I want to have a background music, to do that i put the code at World. Any clue what do i have to do to solve this problem? Thanks.
danpost danpost

2015/3/26

#
ziLaK wrote...
Any clue what do i have to do to solve this problem?
No -- but, what you can do to have a possibility of the problem being solved is post what code you are using for the background music.
ziLaK ziLaK

2015/3/26

#
danpost wrote...
ziLaK wrote...
Any clue what do i have to do to solve this problem?
No -- but, what you can do to have a possibility of the problem being solved is post what code you are using for the background music.
public class GameWorld extends World
{
    private GreenfootSound musica;
    /**
     * Constructor for objects of class GameWorld.
     * 
     */
    public GameWorld()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(400, 600, 1); 
    }
    public void act()
    
    {
        musicaFundo();
    }
        public void musicaFundo()
    {
        musica = new GreenfootSound("musicafundo.mp3");
        musica.;
        musica.setVolume(30);
    }
}
Super_Hippo Super_Hippo

2015/3/26

#
You create a new GreenfootSound object every act-cycle and start it (if in line 21 would be a 'play()' after the dot). Instead, you could put it in the constructor (after line 11) and maybe use the 'playLoop' method.
ziLaK ziLaK

2015/3/26

#
it worked but it is in the construtor, so it plays when i create the scenario but think is the best think i can do, btw I have a sound to when i remove a object and this error appear: Exception in thread "SoundStream:file:/C:/Users/PC/Desktop/projecto%201%20POO/Project1_/sounds/bite.mp3" java.lang.ArrayIndexOutOfBoundsException: 580 the game doesnt stop but it appears, btw thx.
danpost danpost

2015/3/26

#
The exception is probably thrown because there are tags within the mp3 file. See if you can save the sound file without the tags.
ziLaK ziLaK

2015/3/27

#
I saw a post that says to use ID3KILL i tryed and didnt worked
EduandErnst EduandErnst

2015/3/27

#
Try and use "MP3 tag" it's a tool to add/remove tags from mp3 files ...
danpost danpost

2015/3/27

#
You could also try saving the sound file under a different format ("wav" for example).
ziLaK ziLaK

2015/3/27

#
EduandErnst wrote...
Try and use "MP3 tag" it's a tool to add/remove tags from mp3 files ...
Did it and couldnt remove the tag
danpost wrote...
You could also try saving the sound file under a different format ("wav" for example).
Tryed and same thing happen
pitrang pitrang

2015/3/27

#
sorry, this is my first time using greenfoot some sounds file are too large, so i delete them without checking the code. i have it fixed already in update.
pitrang pitrang

2015/3/27

#
sorry, wrong room...
You need to login to post a reply.