public class SoundClip extends Object
Contributors: seb (soi.city.ac.uk) - initial API and implementation Matthias Pfisterer - code for converting compressed formats, adapted from AudioPlayer (http://jsresources.org/); code adapted from AudioPlayer is covered by the following notices: Copyright (c) 1999, 2000 by Matthias Pfisterer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Constructor and Description |
---|
SoundClip(String fileName)
Initialise a new sound clip from the named audio file.
|
SoundClip(URL url)
Initialise a new sound clip from the audio file located at the given url.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Permanently close the clip.
|
protected void |
finalize()
Close the clip if still open when garbage collected.
|
void |
loop()
Start playing the clip in a continuous loop.
|
void |
pause()
Pause the playing of the clip.
|
void |
play()
Play the clip from the start.
|
void |
resume()
Resume playing a paused clip.
|
void |
setVolume(double volume)
Adjust the volume of the sound.
|
void |
stop()
Stop playing the clip.
|
public SoundClip(String fileName) throws UnsupportedAudioFileException, IOException, LineUnavailableException
fileName
- audio file nameUnsupportedAudioFileException
IOException
LineUnavailableException
public SoundClip(URL url) throws UnsupportedAudioFileException, IOException, LineUnavailableException
url
- the location of the audio fileUnsupportedAudioFileException
IOException
LineUnavailableException
public void setVolume(double volume)
volume
- The multiplier to apply to the clip's default volume level.public void play()
public void loop()
public void stop()
public void resume()
public void pause()
public void close()