framework
Class Sound
java.lang.Object
framework.Sound
public class Sound
- extends Object
A Sound
object is created for each audio file used.
You can play the sound multiple times by calling start()
more than once. If you require greater control over playback, you
can obtain a Clip
object from getClip()
.
Clip objects returned from this class may be closed at any time
they are inactive, but they will be automatically reopened at the
original position when start
or loop
is called. You can also reopen them by calling open()
,
which will reset the position to the start of the clip.
To read MP3 or Ogg Vorbis audio files, get the appropriate plugins
from this page.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Sound
public Sound(File file)
throws IOException
- Throws:
IOException
Sound
public Sound(InputStream stream)
throws IOException
- Throws:
IOException
Sound
public Sound(URL url)
throws IOException
- Throws:
IOException
Sound
public Sound(AudioInputStream stream)
throws IOException
- Throws:
IOException
getBytes
public byte[] getBytes()
getFormat
public AudioFormat getFormat()
prepare
public void prepare()
- Calling this method will attempt to load a
Clip
object for this Sound.
You could use this to preload your background music or any other long sound clip.
start
public void start()
getClip
public Clip getClip()
pauseAll
public void pauseAll()
resumeAll
public void resumeAll()
stopAll
public void stopAll()
getPausedClips
public Collection getPausedClips()
getActiveClips
public Collection getActiveClips()
isMuted
public boolean isMuted()
setMuted
public void setMuted(boolean mute)
getVolume
public float getVolume()
setVolume
public void setVolume(float volume)