GreenfootSound+class

greenfoot Class GreenfootSound
java.lang.Object greenfoot.GreenfootSound

关于背景音乐和Actor音乐等发声装置的类

public class GreenfootSound extends java.lang.Object Represents audio that can be played in Greenfoot. A GreenfootSound loads the audio from a file. The sound cannot be played several times simultaneously, but can be played several times sequentially. Most files of the following formats are supported: AIFF, AU, WAV, MP3 and MIDI.

Version: 2.1 Author: Poul Henriksen 保罗 亨里克森

构造方法 Constructor Summary Creates a new sound from the given file.
 * GreenfootSound(java.lang.String filename)**

其他方法 Method Summary True if the sound is currently playing.
 * boolean isPlaying**

void pause Pauses the current sound if it is currently playing. void play Start playing this sound.

Play this sound repeatedly in a loop. void stop Stop playing this sound if it is currently playing. java.lang.String toString Returns a string representation of this sound containing the name of the file and whether it is currently playing or not. Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 * void playLoop** 循环播放

这个类的功能比较简单，，，，，不过能扩展啊！

Constructor Detail GreenfootSound public GreenfootSound(java.lang.String filename)Creates a new sound from the given file.

Parameters: filename - Typically the name of a file in the sounds directory in the project directory. Method Detail play public void playStart playing this sound. If it is playing already, it will do nothing. If the sound is currently looping, it will finish the current loop and stop. If the sound is currently paused, it will resume playback from the point where it was paused. The sound will be played once.

playLoop public void playLoopPlay this sound repeatedly in a loop. If called on an already looping sound, it will do nothing. If the sound is already playing once, it will start looping instead. If the sound is currently paused, it will resume playing from the point where it was paused.

stop public void stopStop playing this sound if it is currently playing. If the sound is played again later, it will start playing from the beginning. If the sound is currently paused it will now be stopped instead.

pause public void pausePauses the current sound if it is currently playing. If the sound is played again later, it will resume from the point where it was paused. Make sure that this is really the method you want. If possible, you should always use stop, because the resources can be released after calling stop. The resources for the sound will not be released while it is paused.

See Also: stop

isPlaying public boolean isPlayingTrue if the sound is currently playing.

toString public java.lang.String toStringReturns a string representation of this sound containing the name of the file and whether it is currently playing or not.

Overrides: toString in class java.lang.Object