|
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.JukeBox
@ThirdParty(value="de.vdheide.mp3") public class JukeBox
A simple JukeBox for MP3Player objects.
Simplest usage: after instanciation, add a few URLs or Files to the list
and call playNext() or restart() - that's it.
Optionally, you can call shuffle() or call playNext()
anytime when you don't want to wait until the current song is over.
For convenience, this class also provides a main() method, that starts
a command line based randomized jukeBox based on a given file or directory
containing songs.
The file extensions supported by this class are:
*.mp3, *.au, *.mid, *.aif, *.rmf, *.wav, *.aiff
In addition to the requirements of the MP3Player class, this class also requires the package de.vdheide.mp3 (see: http://www.vdheide.de/).
MP3Player,
main(String[]),
JJukeBox| Nested Class Summary | |
|---|---|
static interface |
JukeBox.Listener
JukeBox.Listener listens to events triggered by a JukeBox object. |
| Constructor Summary | |
|---|---|
JukeBox()
|
|
| Method Summary | |
|---|---|
boolean |
add(File file)
adds a single File to the playlist; returns true only if the file passed the file filter |
boolean |
add(int atIndex,
File file)
inserts a single File to the playlist at the specified position; returns true only if the file passed the file filter |
void |
add(int atIndex,
URL url)
|
void |
add(URL url)
adds a single URL to the playlist |
void |
addAll(File[] files)
adds those File objects to the playlist that pass the filter |
void |
addAll(URL[] urls)
adds a bunch of URLs to the playlist |
void |
addFromDirectory(File dir)
adds all sound files from the given directory tree recursively. |
void |
addFromFile(File file)
adds all entries in the file to the list. |
void |
addListener(JukeBox.Listener listener)
adds a listener that is notified when a song changes |
void |
clearList()
empties the current playlist |
void |
createSongList(File directory,
File fileToWrite,
boolean appendToFile)
creates a song list from the given directory and writes it to the given file. |
Object |
getCurrentSound()
returns the sound object currently being played |
ExtensionFileFilter |
getFileFilter()
returns the file filter used to filter entries |
protected MP3Player |
getPlayer()
|
List<Object> |
getPlayList()
returns the curret playlist as an unmodifiable list |
static void |
main(String[] args)
starts a comand line based JukeBox with several options. |
void |
musicStopped(SoundPlayer sound)
called internally; notifies listeners that music stopped and then plays the next song |
Object |
play(int index)
starts to play the song indicated by the index. |
void |
playCurrentSongFromStart()
plays current song from the start |
void |
playLast()
plays the last song in the list |
Object |
playNext()
requests the next song in the current list to be played. |
boolean |
remove(Object listItem)
removes the given item (usually File or URL) from the current play list if it exists |
void |
restart()
selects the first song in the list to be played next |
void |
resume()
resumes the music if previously stopped |
void |
shuffle()
shuffles the list |
int |
size()
returns the size of the playlist |
void |
stop()
stops the music; resume with resume() |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JukeBox()
| Method Detail |
|---|
protected MP3Player getPlayer()
public ExtensionFileFilter getFileFilter()
public int size()
public void musicStopped(SoundPlayer sound)
musicStopped in interface SoundPlayer.Listenerpublic Object play(int index)
public Object playNext()
public void stop()
resume()
public void resume()
public void playLast()
public void playCurrentSongFromStart()
public void restart()
public void shuffle()
public List<Object> getPlayList()
public Object getCurrentSound()
public void clearList()
public void addFromDirectory(File dir)
public void addFromFile(File file)
throws IOException
IOExceptioncreateSongList(File, File, boolean)public void addAll(URL[] urls)
public void addAll(File[] files)
public void add(URL url)
public boolean add(File file)
public boolean add(int atIndex,
File file)
public void add(int atIndex,
URL url)
public boolean remove(Object listItem)
public void addListener(JukeBox.Listener listener)
public void createSongList(File directory,
File fileToWrite,
boolean appendToFile)
throws IOException
addFromFile().
This method searches the entire subtree starting from the given directory
and filters by the supported sound file extensions.
IOExceptionaddFromFile(File)
public static void main(String[] args)
throws IOException
You can either directly specify a directory as parameter or
give a filename by prefixing it with '@'; examples:
You can also specify a second parameter; if you use "shuffle" as the
second parameter, the list is shuffled from the start.
"java com.antelmann.sound.JukeBox @c:\mylist.txt" "java com.antelmann.sound.JukeBox @c:\mylist.txt shuffle" "java com.antelmann.sound.JukeBox c:\media\mp3"This command line juke box then understands the following commands while running:
IOException - if any of the specified files could not be read
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||