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

2013/1/12

how to stop music playing?

AceticAcid AceticAcid

2013/1/12

#
There is only playSound method, but not stopSound method. How can I stop it?
Gevater_Tod4711 Gevater_Tod4711

2013/1/12

#
If you use the playSound method you can't stop the sound I think. If you want the sound to stop you have to use the class GreenfootSound. First you create a new sound like this:
1
GreenfootSound sound = new GreenfootSound("filename");// the filename is the same as the one you would use in the playSound method;
You should create this sound as a global one (at the top of your code). Then you can start and stop the sound like this:
1
2
3
4
5
sound.start();//start playing the sound;
sound.stop();//stop playing the sound;
sound.playLoop();//plays the sound over and over again;
 
//also you can use any other mehtod from the GreenfootSound class;
AceticAcid AceticAcid

2013/1/13

#
Thank you very much much much~!!T^T
Fordscorpio2 Fordscorpio2

2013/5/9

#
how you mean it? must i make Import greenfoot sound or what? i wanna stop my sound when i click button 2 can you help me?
Gevater_Tod4711 Gevater_Tod4711

2013/5/9

#
You don't need to import GreenfootSound (it is already imported because the .* means all classes in this package). In the class GreenfootSound there is a method stop which stops the sound. If you post your code I probably can help you with it.
SierraBravo SierraBravo

2014/2/27

#
Cannot find symbol - method start();
danpost danpost

2014/2/28

#
The method to start a GreenfootSound object is 'play' (not 'start').
You need to login to post a reply.