org.xiph.speex.player

Class Player

Implemented Interfaces:
ActionListener
Known Direct Subclasses:
Recorder

public class Player
extends JPanel
implements ActionListener

JavaSound Player. Here is the Finite State Machine describing it's state.
          +----+
          |Init|
          +----+
             V
    ----->+----+
   /     >|Stop| \
  /     / +----+<32\
 /     /         \ V
 | +-----+ ---> +----+
 | |Pause|      |Play|
 | +-----+ <--- +----+
  \     A        / A
   \     \+----+<32/
    ------|Buff| /
          +----+
 
Version:
$Revision: 1.2 $
Author:
Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)

Nested Class Summary

protected class
Player.Playback
Playback thread

Field Summary

static String
BUILD
Build Number
static String
REVISION
Revision Number
protected static int
STATE_BUFFERING
Finite State Machine State: Buffering
protected static int
STATE_ERROR
Finite State Machine State: Error
protected static int
STATE_INIT
Finite State Machine State: Initialised
protected static int
STATE_PAUSED
Finite State Machine State: Paused
protected static int
STATE_PLAYING
Finite State Machine State: Playing
protected static int
STATE_STOPPED
Finite State Machine State: Stopped
static String
VERSION
Version Number
protected URL
audioFile
protected String
audioFilename
protected int
audioLength
protected int
oldstate
Previous State of the Finite State Machine
protected JButton
pauseButton
Pause Button
protected JButton
playButton
Play Button
protected Player.Playback
playback
protected JPanel
playerButtonPane
The Players Button Panel
protected JPanel
playerScrollPane
The Players Scroll Panel
protected JSlider
progressBar
Progress Bar
protected int
state
Current State of the Finite State Machine
protected JButton
stopButton
Stop Button
protected Timer
timer

Constructor Summary

Player(String file)
Build a Player.

Method Summary

void
actionPerformed(ActionEvent e)
Process Actions when button are pressed.
protected static JButton
buildButton(String actionCommand, String toolTip, String pathIconDefault, String pathIconDisabled, String pathIconRollover, ActionListener listener)
Build a Button.
protected void
createButtonPanel()
Create the ButtonPanel for the player.
protected void
createGUI()
Create GUI for the player.
protected static ImageIcon
createImageIcon(String path)
Returns an ImageIcon, or null if the path was invalid.
protected void
createScrollPanel()
Create the ScrollPanel for the player.
protected 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(String[] args)
Command Line entrance.
void
pauseIt()
Pause
void
playIt()
void
start()
Start the Player Component.
void
stop()
Stop the Player Component.
void
stopIt()

Field Details

BUILD

public static final String BUILD
Build Number

REVISION

public static final String REVISION
Revision Number

STATE_BUFFERING

protected static final int STATE_BUFFERING
Finite State Machine State: Buffering
Field Value:
4

STATE_ERROR

protected static final int STATE_ERROR
Finite State Machine State: Error
Field Value:
5

STATE_INIT

protected static final int STATE_INIT
Finite State Machine State: Initialised
Field Value:
0

STATE_PAUSED

protected static final int STATE_PAUSED
Finite State Machine State: Paused
Field Value:
3

STATE_PLAYING

protected static final int STATE_PLAYING
Finite State Machine State: Playing
Field Value:
2

STATE_STOPPED

protected static final int STATE_STOPPED
Finite State Machine State: Stopped
Field Value:
1

VERSION

public static final String VERSION
Version Number

audioFile

protected URL audioFile

audioFilename

protected String audioFilename

audioLength

protected int audioLength

oldstate

protected int oldstate
Previous State of the Finite State Machine

pauseButton

protected JButton pauseButton
Pause Button

playButton

protected JButton playButton
Play Button

playback

protected Player.Playback playback

playerButtonPane

protected JPanel playerButtonPane
The Players Button Panel

playerScrollPane

protected JPanel playerScrollPane
The Players Scroll Panel

progressBar

protected JSlider progressBar
Progress Bar

state

protected int state
Current State of the Finite State Machine

stopButton

protected JButton stopButton
Stop Button

timer

protected Timer timer

Constructor Details

Player

public Player(String file)
Build a Player.
Parameters:
file -

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)
Process Actions when button are pressed. Implemented from ActionListener interface.
Parameters:
e -

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.

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
 | +----+ +-----+ +----+ |
 +-----------------------+
 

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
 | +----+ +-----+ +----+ |
 +-----------------------+
 

createImageIcon

protected static ImageIcon createImageIcon(String path)
Returns an ImageIcon, or null if the path was invalid.
Parameters:
path -
Returns:
an ImageIcon, or null if the path was invalid.

createScrollPanel

protected void createScrollPanel()
Create the ScrollPanel for the player. The player scroll panel that should look something like this:
 
 +-----------------------+
 |  ----|--------------  |  Scroll Panel
 +-----------------------+
 

getAudioStream

protected InputStream getAudioStream()
            throws IOException
Returns an InputSteam containing the Audio to playback.
Returns:
an InputSteam containing the Audio to playback.

getProgress

protected int getProgress()
Return the progress of the playback.
Returns:
the progress of the playback.

init

public void init()
Initialize the Player Component.

main

public static void main(String[] args)
Command Line entrance.
Parameters:
args -

pauseIt

public void pauseIt()
Pause

playIt

public void playIt()

start

public void start()
Start the Player Component.

stop

public void stop()
Stop the Player Component.

stopIt

public void stopIt()

Copyright © 1999-2004 Wimba S.A. All Rights Reserved.