Class Player

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
Recorder

public class Player extends JPanel implements ActionListener
JavaSound Player. Here is the Finite State Machine describing it's state.
          +----+
          |Init|
          +----+
             V
    ----->+----+
   /     >|Stop| \
  /     / +----+invalid input: '<' \
 /     /         \ V
 | +-----+ ---> +----+
 | |Pause|      |Play|
 | +-----+ invalid input: '<'--- +----+
  \     A        / A
   \     \+----+invalid input: '<' /
    ------|Buff| /
          +----+
 
Version:
$Revision: 1.2 $
Author:
Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
See Also:
  • Field Details

    • BUILD

      public static final String BUILD
      Build Number
      See Also:
    • VERSION

      public static final String VERSION
      Version Number
      See Also:
    • REVISION

      public static final String REVISION
      Revision Number
      See Also:
    • STATE_INIT

      protected static final int STATE_INIT
      Finite State Machine State: Initialised
      See Also:
    • STATE_STOPPED

      protected static final int STATE_STOPPED
      Finite State Machine State: Stopped
      See Also:
    • STATE_PLAYING

      protected static final int STATE_PLAYING
      Finite State Machine State: Playing
      See Also:
    • STATE_PAUSED

      protected static final int STATE_PAUSED
      Finite State Machine State: Paused
      See Also:
    • STATE_BUFFERING

      protected static final int STATE_BUFFERING
      Finite State Machine State: Buffering
      See Also:
    • STATE_ERROR

      protected static final int STATE_ERROR
      Finite State Machine State: Error
      See Also:
    • playerScrollPane

      protected JPanel playerScrollPane
      The Players Scroll Panel
    • playerButtonPane

      protected JPanel playerButtonPane
      The Players Button Panel
    • playButton

      protected JButton playButton
      Play Button
    • pauseButton

      protected JButton pauseButton
      Pause Button
    • stopButton

      protected JButton stopButton
      Stop Button
    • progressBar

      protected JSlider progressBar
      Progress Bar
    • timer

      protected 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 String audioFilename
    • audioFile

      protected URL audioFile
    • audioLength

      protected int audioLength
    • playback

      protected Player.Playback playback
  • Constructor Details

    • Player

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

    • main

      public static void main(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 InputStream getAudioStream() throws IOException
      Returns an InputSteam containing the Audio to playback.
      Returns:
      an InputSteam containing the Audio to playback.
      Throws:
      IOException
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Process Actions when button are pressed. Implemented from ActionListener interface.
      Specified by:
      actionPerformed in interface 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 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

      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.