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:
java.awt.event.ActionListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
- Direct Known Subclasses:
Recorder
public class Player extends javax.swing.JPanel implements java.awt.event.ActionListener
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Player.Playback
Playback thread-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.URL
audioFile
protected java.lang.String
audioFilename
protected int
audioLength
static java.lang.String
BUILD
Build Numberprotected int
oldstate
Previous State of the Finite State Machineprotected javax.swing.JButton
pauseButton
Pause Buttonprotected Player.Playback
playback
protected javax.swing.JButton
playButton
Play Buttonprotected javax.swing.JPanel
playerButtonPane
The Players Button Panelprotected javax.swing.JPanel
playerScrollPane
The Players Scroll Panelprotected javax.swing.JSlider
progressBar
Progress Barstatic java.lang.String
REVISION
Revision Numberprotected int
state
Current State of the Finite State Machineprotected static int
STATE_BUFFERING
Finite State Machine State: Bufferingprotected static int
STATE_ERROR
Finite State Machine State: Errorprotected static int
STATE_INIT
Finite State Machine State: Initialisedprotected static int
STATE_PAUSED
Finite State Machine State: Pausedprotected static int
STATE_PLAYING
Finite State Machine State: Playingprotected static int
STATE_STOPPED
Finite State Machine State: Stoppedprotected javax.swing.JButton
stopButton
Stop Buttonprotected javax.swing.Timer
timer
static java.lang.String
VERSION
Version Number-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description Player(java.lang.String file)
Build a Player.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
Process Actions when button are pressed.protected static javax.swing.JButton
buildButton(java.lang.String actionCommand, java.lang.String toolTip, java.lang.String pathIconDefault, java.lang.String pathIconDisabled, java.lang.String pathIconRollover, java.awt.event.ActionListener listener)
Build a Button.protected void
createButtonPanel()
Create the ButtonPanel for the player.protected void
createGUI()
Create GUI for the player.protected static javax.swing.ImageIcon
createImageIcon(java.lang.String path)
Returns an ImageIcon, or null if the path was invalid.protected void
createScrollPanel()
Create the ScrollPanel for the player.protected java.io.InputStream
getAudioStream()
Returns an InputSteam containing the Audio to playback.protected int
getProgress()
Return the progress of the playback.void
init()
Initialize the Player Component.static void
main(java.lang.String[] args)
Command Line entrance.void
pauseIt()
Pausevoid
playIt()
void
start()
Start the Player Component.void
stop()
Stop the Player Component.void
stopIt()
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods 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, update
-
Methods 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, validateTree
-
Methods 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 Detail
-
BUILD
public static final java.lang.String BUILD
Build Number- See Also:
- Constant Field Values
-
VERSION
public static final java.lang.String VERSION
Version Number- See Also:
- Constant Field Values
-
REVISION
public static final java.lang.String REVISION
Revision Number- See Also:
- Constant Field Values
-
STATE_INIT
protected static final int STATE_INIT
Finite State Machine State: Initialised- See Also:
- Constant Field Values
-
STATE_STOPPED
protected static final int STATE_STOPPED
Finite State Machine State: Stopped- See Also:
- Constant Field Values
-
STATE_PLAYING
protected static final int STATE_PLAYING
Finite State Machine State: Playing- See Also:
- Constant Field Values
-
STATE_PAUSED
protected static final int STATE_PAUSED
Finite State Machine State: Paused- See Also:
- Constant Field Values
-
STATE_BUFFERING
protected static final int STATE_BUFFERING
Finite State Machine State: Buffering- See Also:
- Constant Field Values
-
STATE_ERROR
protected static final int STATE_ERROR
Finite State Machine State: Error- See Also:
- Constant Field Values
-
playerScrollPane
protected javax.swing.JPanel playerScrollPane
The Players Scroll Panel
-
playerButtonPane
protected javax.swing.JPanel playerButtonPane
The Players Button Panel
-
playButton
protected javax.swing.JButton playButton
Play Button
-
pauseButton
protected javax.swing.JButton pauseButton
Pause Button
-
stopButton
protected javax.swing.JButton stopButton
Stop Button
-
progressBar
protected javax.swing.JSlider progressBar
Progress Bar
-
timer
protected javax.swing.Timer timer
-
state
protected int state
Current State of the Finite State Machine
-
oldstate
protected int oldstate
Previous State of the Finite State Machine
-
audioFilename
protected java.lang.String audioFilename
-
audioFile
protected java.net.URL audioFile
-
audioLength
protected int audioLength
-
playback
protected Player.Playback playback
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
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
protected java.io.InputStream getAudioStream() throws java.io.IOException
Returns an InputSteam containing the Audio to playback.- Returns:
- an InputSteam containing the Audio to playback.
- Throws:
java.io.IOException
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
Process Actions when button are pressed. Implemented from ActionListener interface.- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- 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 javax.swing.JButton buildButton(java.lang.String actionCommand, java.lang.String toolTip, java.lang.String pathIconDefault, java.lang.String pathIconDisabled, java.lang.String pathIconRollover, java.awt.event.ActionListener listener)
Build a Button.- Parameters:
actionCommand
-toolTip
-pathIconDefault
-pathIconDisabled
-pathIconRollover
-listener
-- Returns:
- the Button that was built.
-
createImageIcon
protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
Returns an ImageIcon, or null if the path was invalid.- Parameters:
path
-- Returns:
- an ImageIcon, or null if the path was invalid.
-
-