jaco.mp3.player
Class MP3Player

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jaco.mp3.player.MP3Player
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class MP3Player
extends javax.swing.JPanel

Java MP3 Player

 new MP3Player(new File("test.mp3")).play();
 

Version:
1.35, May 26, 2010
Author:
Cristian Sulea ( http://cristiansulea .entrust.ro )
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
static java.lang.String UI_CLASS_ID
           
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MP3Player()
           
MP3Player(java.io.File... mp3s)
           
MP3Player(java.net.URL... mp3s)
           
 
Method Summary
 void addMP3PlayerListener(MP3PlayerListener listener)
          Adds a MP3PlayerListener to the player.
 void addToPlayList(java.io.File mp3)
          Appends the specified mp3 (as File object) to the end of the play list.
 void addToPlayList(java.net.URL mp3)
          Appends the specified mp3 (as URL object) to the end of the play list.
 java.util.List<java.net.URL> getPlayList()
          Returns the current play list.
 java.lang.String getUIClassID()
           
 boolean isPaused()
          Determines whether this player is paused.
 boolean isRepeat()
          Returns the repeat state of the player.
 boolean isShuffle()
          Returns the shuffle state of the player.
 boolean isStopped()
          Determines whether this player is stopped.
 void pause()
          Forces the player to pause playing.
 void play()
          Causes this player to start playing (or resume if the player is paused).
 void removeAllMP3PlayerListeners()
          Removes all of the MP3PlayerListener listeners from this player.
 void removeMP3PlayerListener(MP3PlayerListener listener)
          Removes a MP3PlayerListener from the player.
static void setDefaultUI(java.lang.Class<? extends jaco.mp3.player.plaf.MP3PlayerUI> uiClass)
           
 void setRepeat(boolean repeat)
          When you turn on repeat, the player will practically never stop.
 void setShuffle(boolean shuffle)
          When you turn on shuffle, the next mp3 to play will be randomly chosen from the play list.
 void skipBackward()
          Forces the player to play previous mp3 in the play list (or random if shuffle is turned on).
 void skipForward()
          Forces the player to play next mp3 in the play list (or random if shuffle is turned on).
 void stop()
          Forces the player to stop playing.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UI_CLASS_ID

public static final java.lang.String UI_CLASS_ID
Constructor Detail

MP3Player

public MP3Player()

MP3Player

public MP3Player(java.net.URL... mp3s)

MP3Player

public MP3Player(java.io.File... mp3s)
Method Detail

getUIClassID

public java.lang.String getUIClassID()
Overrides:
getUIClassID in class javax.swing.JPanel

setDefaultUI

public static void setDefaultUI(java.lang.Class<? extends jaco.mp3.player.plaf.MP3PlayerUI> uiClass)

play

public void play()
Causes this player to start playing (or resume if the player is paused). This is a non blocking method, with the result that two threads are running concurrently: the current thread (which returns from the call to the play() method) and another thread (which executes the actual play: stream read/decode, audio data write).

See Also:
pause(), stop()

pause

public void pause()
Forces the player to pause playing.

See Also:
play()

stop

public void stop()
Forces the player to stop playing.

See Also:
play()

skipForward

public void skipForward()
Forces the player to play next mp3 in the play list (or random if shuffle is turned on).

See Also:
play()

skipBackward

public void skipBackward()
Forces the player to play previous mp3 in the play list (or random if shuffle is turned on).

See Also:
play()

isPaused

public boolean isPaused()
Determines whether this player is paused.

Returns:
true if the player is paused, false otherwise
See Also:
pause()

isStopped

public boolean isStopped()
Determines whether this player is stopped.

Returns:
true if the player is stopped, false otherwise
See Also:
stop()

addMP3PlayerListener

public void addMP3PlayerListener(MP3PlayerListener listener)
Adds a MP3PlayerListener to the player.

Parameters:
listener - the listener to be added

removeMP3PlayerListener

public void removeMP3PlayerListener(MP3PlayerListener listener)
Removes a MP3PlayerListener from the player.

Parameters:
listener - the listener to be removed

removeAllMP3PlayerListeners

public void removeAllMP3PlayerListeners()
Removes all of the MP3PlayerListener listeners from this player.


addToPlayList

public void addToPlayList(java.net.URL mp3)
Appends the specified mp3 (as URL object) to the end of the play list.

Parameters:
mp3 - the mp3 to be added
See Also:
addToPlayList(File), getPlayList()

addToPlayList

public void addToPlayList(java.io.File mp3)
Appends the specified mp3 (as File object) to the end of the play list.

Parameters:
mp3 - the mp3 to be added
See Also:
addToPlayList(URL), getPlayList()

getPlayList

public java.util.List<java.net.URL> getPlayList()
Returns the current play list.

Returns:
the current play list as URL objects
See Also:
addToPlayList(URL), addToPlayList(File)

isShuffle

public boolean isShuffle()
Returns the shuffle state of the player. True if the shuffle is on, false if it's not.

Returns:
true if the shuffle is on, false otherwise
See Also:
setShuffle(boolean)

setShuffle

public void setShuffle(boolean shuffle)
When you turn on shuffle, the next mp3 to play will be randomly chosen from the play list.

Parameters:
shuffle - true if shuffle should be turned on, or false for turning off
See Also:
isShuffle()

isRepeat

public boolean isRepeat()
Returns the repeat state of the player. True if the repeat is on, false if it's not.

Returns:
true if the repeat is on, false otherwise
See Also:
setRepeat(boolean)

setRepeat

public void setRepeat(boolean repeat)
When you turn on repeat, the player will practically never stop. After the last mp3 from the play list will finish, the first will be automatically played, or a random one if shuffle is on.

Parameters:
repeat - true if repeat should be turned on, or false for turning off
See Also:
isRepeat()