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

2012/3/13

Sound Help

1
2
danpost danpost

2012/3/13

#
Did you change 'String song = "01 Lonely Boy.mp3";' in line 11 of the Jukebox world class to 'GreenfootSound song = null;' AND change line 23 in the Jukebox world (in the setSong method) to 'if(song != null) song.stop();'? And if true to both, what was the complete error message you got (copy/paste here).
danpost danpost

2012/3/13

#
Time to retire for the evening. Really wanted to resolve this by now. Maybe catch up with you tomorrow (about 16 hours or so).
Sneaky4296 Sneaky4296

2012/3/13

#
Cannot find symbol: Method stop --It's on line 25
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Jukebox here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Jukebox extends World
{
    String song= null;
    /**
     * Constructor for objects of class Jukebox.
     * 
     */
    public Jukebox()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1); 
    }
    public void setSong(String filename)
    {
        if (song != null)
        {
            song.stop();
        }
        song = new GreenfootSound(filename);
        song.play();
    }
}
Sneaky4296 Sneaky4296

2012/3/13

#
danpost, thank you for all your help. I got it working.
You need to login to post a reply.
1
2