|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.sound.SoundPlayer
com.antelmann.sound.MP3Player
@ThirdParty(value="javazoom.jl") public class MP3Player
MP3Player extends SoundPlayer's capabilities to play MP3 media.
Note on 3rd party dependancy:
The MP3 capabilities in this class use the third-party class
javazoom.jl.player.Player from the following library:
JavaLayer from JavaZOOM (version tested here: 0.2).
That class library - just like this one - is available under the GNU GPL.
Go to http://www.javazoom.net/ to download the library.
If the media in use is MP3, certain functionality is
restricted as these functions are not easily exposed by JavaLayer.
The following method will act as if no current sound was present
if the current sound source is MP3:
setMicrosecondPosition(long microseconds)getMicrosecondLength() will only return a useful
value, if the current sound source is a mp3 file, where the length property
can be read from the file header.
Finally, the JavaZOOM library does not throw an exception if the
given sound source is not valid MP3 audio data when calling load()
or play(). Therefore - given an invalid source of data
that may in fact not be audio data at all, this player will assume that
it is MP3 audio data - even if it is not. The only way this surfaces is
that the play() method simply signals 'end of song' immediately.
SoundPlayer| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.antelmann.sound.SoundPlayer |
|---|
SoundPlayer.Listener |
| Field Summary |
|---|
| Fields inherited from class com.antelmann.sound.SoundPlayer |
|---|
audioStream, clip, currentSoundSource, sequence, sequencer |
| Constructor Summary | |
|---|---|
MP3Player()
|
|
MP3Player(File file)
|
|
MP3Player(InputStream stream)
|
|
MP3Player(URL url)
|
|
| Method Summary | |
|---|---|
void |
close()
closes the current sound. |
protected void |
finalize()
|
long |
getMicrosecondLength()
if no active sound object is present, -1 is returned; note that this doesn't return milliseconds but microseconds; also, for sampled audio data, the length may be not accurate. |
long |
getMicrosecondPosition()
returns the current microsecond position of the active sound object; returns -1 if no active sound object present |
String |
getSongInfo()
returns the info for the current sound as a String to be displayed |
String |
getSoundTypeDescription()
|
boolean |
isMP3()
|
boolean |
isPlaying()
|
protected void |
load(Object sound)
handles File and URL objects |
void |
play()
if play() is called on a sound that has been
played through, you may have to call stop() before
play() will have the effect of replaying the sound |
void |
stop()
use play() to resume playing after stop() was called |
| Methods inherited from class com.antelmann.sound.SoundPlayer |
|---|
addListener, beep, getCurrentSoundSource, load, load, load, load, notifyListeners, play, playAndWait, setMicrosecondPosition |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MP3Player()
throws SoundException
SoundException
public MP3Player(File file)
throws SoundException
SoundException
public MP3Player(URL url)
throws SoundException
SoundException
public MP3Player(InputStream stream)
throws SoundException
SoundException| Method Detail |
|---|
protected void load(Object sound)
throws SoundException
SoundPlayer
load in class SoundPlayerSoundExceptionpublic String getSoundTypeDescription()
getSoundTypeDescription in class SoundPlayerpublic String getSongInfo()
SoundPlayer
getSongInfo in class SoundPlayerpublic long getMicrosecondLength()
SoundPlayer
getMicrosecondLength in class SoundPlayerSoundPlayer.getMicrosecondPosition(),
SoundPlayer.setMicrosecondPosition(long)public long getMicrosecondPosition()
SoundPlayer
getMicrosecondPosition in class SoundPlayerSoundPlayer.setMicrosecondPosition(long),
SoundPlayer.getMicrosecondLength()public boolean isMP3()
public void close()
SoundPlayerload(..) methods
close in class SoundPlayerpublic void play()
SoundPlayerplay() is called on a sound that has been
played through, you may have to call stop() before
play() will have the effect of replaying the sound
play in class SoundPlayerSoundPlayer.stop()public boolean isPlaying()
isPlaying in class SoundPlayerpublic void stop()
SoundPlayer
stop in class SoundPlayerSoundPlayer.play()protected void finalize()
finalize in class SoundPlayer
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||