Exception in thread "SoundStream:file:/C:/Users/villa/OneDrive/Documents/Bomb%20Bouncers/sounds/Field4.mp3" Exception in thread "SoundStream:file:/C:/Users/villa/OneDrive/Documents/Bomb%20Bouncers/sounds/Field4.mp3" java.lang.ArrayIndexOutOfBoundsException: Index 580 out of bounds for length 580
at javazoom.jl.decoder.LayerIIIDecoder.huffman_decode(LayerIIIDecoder.java:795)
at javazoom.jl.decoder.LayerIIIDecoder.decode(LayerIIIDecoder.java:278)
at javazoom.jl.decoder.LayerIIIDecoder.decodeFrame(LayerIIIDecoder.java:219)
at javazoom.jl.decoder.Decoder.decodeFrame(Decoder.java:147)
at greenfoot.sound.Mp3AudioInputStream.read(Mp3AudioInputStream.java:230)
at greenfoot.sound.SoundStream.run(SoundStream.java:255)
at java.base/java.lang.Thread.run(Thread.java:834)
I keep getting this error whenever I run the title screen after playing a level in my game. Whenever I reset after getting a game over, this happens. I don't know why.
Here's the code for the title screen:
EDIT: I realized that some people may ask for the level code, so here it is, just in case it narrows it down, as well as the game over code:
public class titleScreen extends World
{
public static final GreenfootSound backgroundMusic = new GreenfootSound("Field4.mp3");
/**
* Constructor for objects of class titleScreen.
*
*/
public titleScreen()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
prepare();
backgroundMusic.playLoop();
Greenfoot.start();
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
Play play = new Play();
addObject(play,205,126);
Help help = new Help();
addObject(help,368,217);
Credits credits = new Credits();
addObject(credits,205,293);
}
}public class firstLevel extends World
{
/**
* Constructor for objects of class MyWorld.
*
*/
public int score;
public int i;
public int scoreTick;
public int spawnTimerSpeedUp;
public int spawnTimerSpeedDown;
public int spawnTimerBallSpeedUp;
public int spawnTimerBallSpeedDown;
public int spawnTimerScoreUp;
public int spawnTimerScoreDown;
public int spawnTimerReverseControls;
public int spawnTimerTransparentBall;
public int spawnTimerFog;
public int spawnTimerEMP;
private int timerThingSpeedUp = getRandomNumber(755, 1000);
private int timerThingSpeedDown = getRandomNumber(768, 1100);
private int timerThingBallSpeedUp = getRandomNumber(843, 1231);
private int timerThingBallSpeedDown = getRandomNumber(752, 1500);
private int timerThingScoreUp = getRandomNumber(600, 1200);
private int timerThingScoreDown = getRandomNumber(832, 1311);
private int timerThingReverseControls = getRandomNumber(713, 912);
private int timerThingTransparentBall = getRandomNumber(900, 1321);
private int timerThingFog = getRandomNumber(1200, 1542);
private int timerThingEMP = getRandomNumber(1000, 1329);
private Paddle thePaddle;
private Ball theBall;
private Fog theFog = new Fog();
private EMPGrenade theEMP = new EMPGrenade();
private EMPBlast theBlast = new EMPBlast();
private Counter scoreCounter;
public static final GreenfootSound backgroundMusic = new GreenfootSound("03_Otherworldly_Corridor.mp3");
public firstLevel()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
setPaintOrder(Counter.class, Fog.class, EMPBlast.class, EMPGrenade.class, Paddle.class, Ball.class, PaddleSpeedUp.class, PaddleSpeedDown.class, BallSpeedUp.class, BallSpeedDown.class, PlusFivePoints.class, MinusFivePoints.class, ReverseControls.class, TransparentBall.class, FogBall.class, EMPBallDrop.class);
scoreCounter = new Counter("Score: ");
addObject(scoreCounter, 300, 20);
backgroundMusic.playLoop();
prepare();
}
public void act(){
randomlySpawnSpeedUp();
randomlySpawnSpeedDown();
randomlySpawnBallSpeedUp();
randomlySpawnBallSpeedDown();
randomlySpawnScoreUp();
randomlySpawnScoreDown();
randomlySpawnReverseControls();
randomlySpawnTransparentBall();
randomlySpawnFog();
randomlySpawnEMP();
scoreTick++;
if(scoreTick%60==0){
score++;
}
scoreCounter.setValue(score);
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
theBall = new Ball();
addObject(theBall,300,144);
thePaddle = new Paddle();
addObject(thePaddle,300,337);
Ground ground = new Ground();
addObject(ground,300,399);
}
public void randomlySpawnSpeedUp(){
spawnTimerSpeedUp = (spawnTimerSpeedUp+1)%timerThingSpeedUp; // repeat every 10 seconds (about)
if (spawnTimerSpeedUp == 0) // at each timer reset
{
timerThingSpeedUp = getRandomNumber(755, 1000);
addObject(new PaddleSpeedUp(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnSpeedDown(){
spawnTimerSpeedDown = (spawnTimerSpeedDown+1)%timerThingSpeedDown; // repeat every 10 seconds (about)
if (spawnTimerSpeedDown == 0) // at each timer reset
{
timerThingSpeedDown = getRandomNumber(768, 1100);
addObject(new PaddleSpeedDown(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnBallSpeedUp(){
spawnTimerBallSpeedUp = (spawnTimerBallSpeedUp+1)%timerThingBallSpeedUp; // repeat every 10 seconds (about)
if (spawnTimerBallSpeedUp == 0) // at each timer reset
{
timerThingBallSpeedUp = getRandomNumber(843, 1231);
addObject(new BallSpeedUp(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnBallSpeedDown(){
spawnTimerBallSpeedDown = (spawnTimerBallSpeedDown+1)%timerThingBallSpeedDown; // repeat every 10 seconds (about)
if (spawnTimerBallSpeedDown == 0) // at each timer reset
{
timerThingBallSpeedDown = getRandomNumber(752, 1500);
addObject(new BallSpeedDown(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnScoreUp(){
spawnTimerScoreUp = (spawnTimerScoreUp+1)%timerThingScoreUp; // repeat every 10 seconds (about)
if (spawnTimerScoreUp == 0) // at each timer reset
{
timerThingScoreUp = getRandomNumber(600, 1200);
addObject(new PlusFivePoints(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnScoreDown(){
spawnTimerScoreUp = (spawnTimerScoreUp+1)%timerThingScoreUp; // repeat every 10 seconds (about)
if (spawnTimerScoreUp == 0) // at each timer reset
{
timerThingScoreUp = getRandomNumber(832, 1311);
addObject(new PlusFivePoints(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnReverseControls(){
spawnTimerReverseControls = (spawnTimerReverseControls+1)%timerThingReverseControls; // repeat every 10 seconds (about)
if (spawnTimerReverseControls == 0) // at each timer reset
{
timerThingReverseControls = getRandomNumber(713, 912);
addObject(new ReverseControls(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnTransparentBall(){
spawnTimerTransparentBall = (spawnTimerTransparentBall+1)%timerThingTransparentBall; // repeat every 10 seconds (about)
if (spawnTimerTransparentBall == 0) // at each timer reset
{
timerThingTransparentBall = getRandomNumber(900, 1321);
addObject(new TransparentBall(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnFog(){
spawnTimerFog = (spawnTimerFog+1)%timerThingFog; // repeat every 10 seconds (about)
if (spawnTimerFog == 0) // at each timer reset
{
timerThingFog = getRandomNumber(900, 1321);
addObject(new FogBall(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void randomlySpawnEMP(){
spawnTimerEMP = (spawnTimerEMP+1)%timerThingEMP; // repeat every 10 seconds (about)
if (spawnTimerEMP == 0) // at each timer reset
{
timerThingEMP = getRandomNumber(1000, 1329);
addObject(new EMPBallDrop(), Greenfoot.getRandomNumber(600), Greenfoot.getRandomNumber(290));
}
}
public void showFog(){
addObject(theFog,300,getRandomNumber(110,227));
}
public void callGrenade(){
addObject(theEMP,theBall.x,theBall.y);
}
public void callBlast(){
addObject(theBlast,empX(),empY());
}
public int getRandomNumber(int start, int end){
int normal = Greenfoot.getRandomNumber(end-start+1);
return normal+start;
}
public Paddle getPaddle(){
return thePaddle;
}
public Ball getBall(){
return theBall;
}
public Counter getCounter(){
return scoreCounter;
}
public Fog getFog(){
return theFog;
}
public EMPGrenade getEMP(){
return theEMP;
}
public int empX(){
return theEMP.x;
}
public int empY(){
return theEMP.y;
}
public EMPBlast getBlast(){
return theBlast;
}
public int getScore(){
return score;
}
}public class GameOver extends World
{
GreenfootSound explosion = new GreenfootSound("Explosion+11.mp3");
/**
* Constructor for objects of class GameOver.
*
*/
public GameOver()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
explosion.play();
Greenfoot.stop();
}
}
