Package org.xiph.speex.player
Class Player
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.xiph.speex.player.Player
- All Implemented Interfaces:
ActionListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible
- Direct Known Subclasses:
Recorder
JavaSound Player.
Here is the Finite State Machine describing it's state.
+----+
|Init|
+----+
V
----->+----+
/ >|Stop| \
/ / +----+< \
/ / \ V
| +-----+ ---> +----+
| |Pause| |Play|
| +-----+ <--- +----+
\ A / A
\ \+----+< /
------|Buff| /
+----+
- Version:
- $Revision: 1.2 $
- Author:
- Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected URLprotected Stringprotected intstatic final StringBuild Numberprotected intPrevious State of the Finite State Machineprotected JButtonPause Buttonprotected Player.Playbackprotected JButtonPlay Buttonprotected JPanelThe Players Button Panelprotected JPanelThe Players Scroll Panelprotected JSliderProgress Barstatic final StringRevision Numberprotected intCurrent State of the Finite State Machineprotected static final intFinite State Machine State: Bufferingprotected static final intFinite State Machine State: Errorprotected static final intFinite State Machine State: Initialisedprotected static final intFinite State Machine State: Pausedprotected static final intFinite State Machine State: Playingprotected static final intFinite State Machine State: Stoppedprotected JButtonStop Buttonprotected Timerstatic final StringVersion NumberFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess Actions when button are pressed.protected static JButtonbuildButton(String actionCommand, String toolTip, String pathIconDefault, String pathIconDisabled, String pathIconRollover, ActionListener listener) Build a Button.protected voidCreate the ButtonPanel for the player.protected voidCreate GUI for the player.protected static ImageIconcreateImageIcon(String path) Returns an ImageIcon, or null if the path was invalid.protected voidCreate the ScrollPanel for the player.protected InputStreamReturns an InputSteam containing the Audio to playback.protected intReturn the progress of the playback.voidinit()Initialize the Player Component.static voidCommand Line entrance.voidpauseIt()PausevoidplayIt()voidstart()Start the Player Component.voidstop()Stop the Player Component.voidstopIt()Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
BUILD
Build Number- See Also:
-
VERSION
Version Number- See Also:
-
REVISION
Revision Number- See Also:
-
STATE_INIT
protected static final int STATE_INITFinite State Machine State: Initialised- See Also:
-
STATE_STOPPED
protected static final int STATE_STOPPEDFinite State Machine State: Stopped- See Also:
-
STATE_PLAYING
protected static final int STATE_PLAYINGFinite State Machine State: Playing- See Also:
-
STATE_PAUSED
protected static final int STATE_PAUSEDFinite State Machine State: Paused- See Also:
-
STATE_BUFFERING
protected static final int STATE_BUFFERINGFinite State Machine State: Buffering- See Also:
-
STATE_ERROR
protected static final int STATE_ERRORFinite State Machine State: Error- See Also:
-
playerScrollPane
The Players Scroll Panel -
playerButtonPane
The Players Button Panel -
playButton
Play Button -
pauseButton
Pause Button -
stopButton
Stop Button -
progressBar
Progress Bar -
timer
-
state
protected int stateCurrent State of the Finite State Machine -
oldstate
protected int oldstatePrevious State of the Finite State Machine -
audioFilename
-
audioFile
-
audioLength
protected int audioLength -
playback
-
-
Constructor Details
-
Player
Build a Player.- Parameters:
file-
-
-
Method Details
-
main
Command Line entrance.- Parameters:
args-
-
init
public void init()Initialize the Player Component. -
start
public void start()Start the Player Component. -
stop
public void stop()Stop the Player Component. -
getAudioStream
Returns an InputSteam containing the Audio to playback.- Returns:
- an InputSteam containing the Audio to playback.
- Throws:
IOException
-
actionPerformed
Process Actions when button are pressed. Implemented from ActionListener interface.- Specified by:
actionPerformedin interfaceActionListener- Parameters:
e-
-
stopIt
public void stopIt() -
playIt
public void playIt() -
pauseIt
public void pauseIt()Pause -
getProgress
protected int getProgress()Return the progress of the playback.- Returns:
- the progress of the playback.
-
createGUI
protected void createGUI()Create GUI for the player. The player panel that should look something like this:+-----------------------+ | ----|-------------- | Scroll Panel +-----------------------+ | +----+ +-----+ +----+ | | |play| |pause| |stop| | Button Panel | +----+ +-----+ +----+ | +-----------------------+
-
createScrollPanel
protected void createScrollPanel()Create the ScrollPanel for the player. The player scroll panel that should look something like this:+-----------------------+ | ----|-------------- | Scroll Panel +-----------------------+
-
createButtonPanel
protected void createButtonPanel()Create the ButtonPanel for the player. The player button panel that should look something like this:+-----------------------+ | +----+ +-----+ +----+ | | |play| |pause| |stop| | Button Panel | +----+ +-----+ +----+ | +-----------------------+
-
buildButton
protected static JButton buildButton(String actionCommand, String toolTip, String pathIconDefault, String pathIconDisabled, String pathIconRollover, ActionListener listener) Build a Button.- Parameters:
actionCommand-toolTip-pathIconDefault-pathIconDisabled-pathIconRollover-listener-- Returns:
- the Button that was built.
-
createImageIcon
Returns an ImageIcon, or null if the path was invalid.- Parameters:
path-- Returns:
- an ImageIcon, or null if the path was invalid.
-