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

2012/1/29

Help with background music :)

programmar programmar

2012/1/29

#
Hey. I'm new to programming and all, yada yada yada noob stuff. Anyways, I need help making background music play when I start a program. I also don't know how to upload mp3 files onto Greenfoot. I'm not sure if these codes - http://www.greenfoot.org/topics/243 - work or not because I don't know how to do stuff with mp3 files. Please help, and thanks in advance ^_^.
davmac davmac

2012/1/29

#
Copy the files into the "sounds" folder inside the scenario folder; then you can use the code from the discussion you linked to.
programmar programmar

2012/1/29

#
So I have to put the sounds folder inside the scenario folder?
danpost danpost

2012/1/29

#
When you create a new scenario, a 'sounds' folder is created within it. Just copy/paste the sound FILES into it. So, do not put an external sounds FOLDER inside the scenario sounds folder, just put the sound FILES inside the scenario sounds folder.
programmar programmar

2012/1/29

#
Okay, so I got the mp3 file into the sounds folder which is in my scenario folder. Now when I use this code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Ground here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Ground extends Actor
{
    /**
     * Act - do whatever the Ground wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {   
    }
private GreenfootSound music = new GreenfootSound("Hyrule Field Main Theme.mp3"); 
public void started()  
{  
    music.playLoop();  
}  
  
public void stopped()  
{  
    music.stop();  
} 
}
it does not bring up an error code. but no music is playing. I have my speakers on too.
programmar programmar

2012/1/29

#
Oh and yes, I pressed start.
kiarocks kiarocks

2012/1/29

#
If you want to use started and stopped, you need to make Ground your world.
kiarocks kiarocks

2012/1/29

#
Double post!
programmar programmar

2012/1/29

#
I moved the code into the world, and it works now! Thanks to everyone who helped!
You need to login to post a reply.