|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.util.SoundPlayer
public class SoundPlayer
Class for playing sound files using file streaming in a separate thread. Sound format supported: WAV, ALAW, ULAW For MP3 format, use class SoundPlayerExt.
SoundPlayerExt
Constructor Summary | |
---|---|
SoundPlayer(javax.sound.sampled.AudioInputStream audioInputStream)
Same as SoundPlayer(audioInputStream, mixerIndex) using the default sound device. |
|
SoundPlayer(javax.sound.sampled.AudioInputStream audioInputStream,
int mixerIndex)
Construct a sound player attached to the given AudioInputStream using the given mixer index (sound device). |
|
SoundPlayer(byte[] ary,
javax.sound.sampled.AudioFormat audioFormat)
Same as SoundPlayer(byte[] ary, AudioFormat audioFormat, int mixerIndex) using the default sound device. |
|
SoundPlayer(byte[] ary,
javax.sound.sampled.AudioFormat audioFormat,
int mixerIndex)
Construct a sound player with data from the given byte array using the given mixer index (sound device). |
|
SoundPlayer(java.io.ByteArrayOutputStream os,
javax.sound.sampled.AudioFormat audioFormat)
Same as SoundPlayer(os, audioFormat, mixerIndex) using the default sound device. |
|
SoundPlayer(java.io.ByteArrayOutputStream os,
javax.sound.sampled.AudioFormat audioFormat,
int mixerIndex)
Construct a sound player with data from the given ByteArrayOutputStream using the given mixer index (sound device). |
|
SoundPlayer(java.io.File audioFile)
Same as SoundPlayer(audioFile, mixerIndex) using the default sound device. |
|
SoundPlayer(java.io.File audioFile,
int mixerIndex)
Construct a sound player attached to given File instance using the given mixer index (sound device). |
|
SoundPlayer(int[] ary,
javax.sound.sampled.AudioFormat audioFormat)
Same as SoundPlayer(int[] ary, AudioFormat audioFormat, int mixerIndex) using the default sound device. |
|
SoundPlayer(int[] ary,
javax.sound.sampled.AudioFormat audioFormat,
int mixerIndex)
Construct a sound player with data from the given int array using the given mixer index (sound device). |
|
SoundPlayer(java.lang.Object resourceObj,
java.lang.String audioPathname)
Same as SoundPlayer(obj, audioPathname, mixerIndex) using the default sound device. |
|
SoundPlayer(java.lang.Object resourceObj,
java.lang.String audioPathname,
int mixerIndex)
Construct a sound player attached to given pathname from a JAR archive using the given mixer index (sound device). |
|
SoundPlayer(java.lang.String audioPathname)
Same as SoundPlayer(audioPathname, mixerIndex) using the default sound device. |
|
SoundPlayer(java.lang.String audioPathname,
int mixerIndex)
Construct a sound player attached to given pathname (relative or fully qualified) using the given mixer index (sound device). |
|
SoundPlayer(java.net.URL url)
Same as SoundPlayer(url, mixerIndex) using the default sound device. |
|
SoundPlayer(java.net.URL url,
int mixerIndex)
Construct a sound player attached to given URL using the given mixer index (sound device). |
Method Summary | |
---|---|
void |
addSoundConverter(SoundConverter soundConverter)
Registers a sound converter. |
void |
addSoundPlayerListener(SoundPlayerListener listener)
Register a SoundPlayerListener to get notifications from the SoundPlayer. |
void |
advanceFrames(long nbFrames)
Advance current position (number of frames). |
void |
advanceTime(double time)
Advance current time (in ms). |
void |
blockingPlay()
Start playing and block until the sound file is completely played. |
static void |
delay(long time)
Suspend thread execution for the given amount of time (in ms). |
static java.lang.String[] |
getAvailableMixers()
Return a list of the names of available mixers (sound devices). |
long |
getCurrentPos()
Return the current position (in frames from beginning). |
double |
getCurrentTime()
Return the current time (in ms from beginning). |
javax.sound.sampled.AudioFormat |
getFormat()
Return AudioFormat of player's (decoded) resource. |
float |
getFrameRate()
Return frame rate (number of frames per seconds) of player's (decoded) resource. |
int |
getFrameSize()
Return frame size (nb of bytes per sound sample) of player's (decoded) resource. |
int |
getMixerIndex()
|
static int[] |
getMono(javax.sound.sampled.AudioInputStream ais)
Return the sound data of the given AudioInputStream in a integer array. |
static int[] |
getStereo(javax.sound.sampled.AudioInputStream ais)
Return the sound data in given AudioInputStream in a integer array. |
int |
getVolume()
Return the current volume (range 0..1000). |
static java.lang.String |
getWavInfo(java.lang.String filename)
Return the audio file format information. |
static int[] |
getWavMono(java.lang.String filename)
Return the sound data of the given WAV file in a integer array. |
static byte[] |
getWavRaw(java.lang.String filename)
Return the raw byte data of the give WAV file. |
static int[] |
getWavStereo(java.lang.String filename)
Return the sound data of the given WAV file in a integer array. |
boolean |
isPlaying()
Return true, if playing (and not pausing), otherwise false. |
void |
mute(boolean isMuting)
If isMuting is true, set sound level to mimimum; otherwise reset it to the old value. |
void |
pause()
Stop playing momentarily. |
int |
play()
Start or resume playing and return immediately. |
void |
playLoop()
Start a loop playing mode, e.g. when the playing ends, it is restarted automatically until stop() is called. |
void |
replay()
Wait until a playing underway has ended. |
void |
rewindFrames(long nbFrames)
Rewind current position (number of frames). |
void |
rewindTime(double time)
Rewind current time (in ms). |
void |
setVolume(int value)
Set the volume to the give value (range 0..1000). |
void |
stop()
Stop playing. |
static java.net.URL |
URLfromJAR(java.lang.String audioPath)
Return the URL of a sound resource from the JAR archive. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SoundPlayer(java.net.URL url, int mixerIndex)
URL url = Thread.currentThread().getContextClassLoader().getResource("<relPath>");
java.lang.RuntimeException
- if sound initialization failspublic SoundPlayer(java.net.URL url)
public SoundPlayer(java.lang.Object resourceObj, java.lang.String audioPathname, int mixerIndex)
public SoundPlayer(java.lang.Object resourceObj, java.lang.String audioPathname)
public SoundPlayer(java.io.File audioFile, int mixerIndex)
java.lang.RuntimeException
- if sound initialization failspublic SoundPlayer(java.io.File audioFile)
public SoundPlayer(java.lang.String audioPathname, int mixerIndex)
java.lang.RuntimeException
- if sound initialization failspublic SoundPlayer(java.lang.String audioPathname)
public SoundPlayer(javax.sound.sampled.AudioInputStream audioInputStream, int mixerIndex)
java.lang.RuntimeException
- if sound initialization failspublic SoundPlayer(javax.sound.sampled.AudioInputStream audioInputStream)
public SoundPlayer(java.io.ByteArrayOutputStream os, javax.sound.sampled.AudioFormat audioFormat, int mixerIndex)
java.lang.RuntimeException
- if sound initialization failspublic SoundPlayer(java.io.ByteArrayOutputStream os, javax.sound.sampled.AudioFormat audioFormat)
public SoundPlayer(byte[] ary, javax.sound.sampled.AudioFormat audioFormat, int mixerIndex)
java.lang.RuntimeException
- if sound initialization failspublic SoundPlayer(byte[] ary, javax.sound.sampled.AudioFormat audioFormat)
public SoundPlayer(int[] ary, javax.sound.sampled.AudioFormat audioFormat, int mixerIndex)
java.lang.RuntimeException
- if sound initialization failspublic SoundPlayer(int[] ary, javax.sound.sampled.AudioFormat audioFormat)
Method Detail |
---|
public void addSoundPlayerListener(SoundPlayerListener listener)
public void replay()
public int play()
public void blockingPlay()
public void stop()
public void pause()
public boolean isPlaying()
public long getCurrentPos()
public double getCurrentTime()
public javax.sound.sampled.AudioFormat getFormat()
AudioFormat
public int getFrameSize()
public float getFrameRate()
public void advanceFrames(long nbFrames)
public void advanceTime(double time)
public void rewindFrames(long nbFrames)
public void rewindTime(double time)
public void setVolume(int value)
public void mute(boolean isMuting)
public int getVolume()
public static java.lang.String[] getAvailableMixers()
public int getMixerIndex()
public void addSoundConverter(SoundConverter soundConverter)
SoundConverter
public void playLoop()
public static byte[] getWavRaw(java.lang.String filename)
public static int[] getStereo(javax.sound.sampled.AudioInputStream ais)
public static int[] getWavStereo(java.lang.String filename)
public static int[] getMono(javax.sound.sampled.AudioInputStream ais)
public static int[] getWavMono(java.lang.String filename)
public static java.lang.String getWavInfo(java.lang.String filename)
public static java.net.URL URLfromJAR(java.lang.String audioPath)
public static void delay(long time)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |