Currently I have 5 buttons that play songs. The pause and stop buttons are not executing the pause and stop commands. How do I get them to execute the pause and stop commands?
public class Button extends Actor
{
private static int songPlaying = 0;
private static boolean isPaused = false;
private String image;
private String song;
private int buttonType;
private GreenfootSound gfs;
private boolean isMouseClicked;
public Button(String imageName, String songName, int typeOfButton)
{
image = imageName;
setImage(image);
song = songName;
gfs = new GreenfootSound(song);
buttonType = typeOfButton;
}
public void act()
{
isMouseClicked = Greenfoot.mouseClicked(this);
checkSongPlaying();
}
private void checkSongPlaying()
{
if (isMouseClicked)
{
getWorld().showText("Button type: " + buttonType + ", song name: '" + song + "'", 250, 320);
gfs.play();
}
if (isMouseClicked && buttonType < 0)
{
if (songPlaying == 0)
{
getWorld().showText("Song is Stopped!", 250, 380);
gfs.stop();
}
else
{
getWorld().showText("Song is Paused " + songPlaying, 250, 380);
songPlaying = 0;
isPaused=false;
}
}
if (isMouseClicked && songPlaying == 0 && buttonType > 0)
{
getWorld().showText("Starting song " + buttonType + " named " + song, 250, 380);
songPlaying = buttonType;
}
}
}

