com.melloware.jukes.gui.tool
Class Player

java.lang.Object
  extended by com.melloware.jukes.gui.tool.Player
All Implemented Interfaces:
javazoom.jlgui.basicplayer.BasicPlayerListener

public final class Player
extends java.lang.Object
implements javazoom.jlgui.basicplayer.BasicPlayerListener

This class implements a simple player based on BasicPlayer. BasicPlayer is a threaded class providing most features of a music player. BasicPlayer works with underlying JavaSound SPIs to support multiple audio formats. Basically JavaSound supports WAV, AU, AIFF audio formats. Add MP3 SPI and Vorbis SPI in your CLASSPATH to play MP3 and Ogg Vorbis file.

Copyright (c) 1999-2007 Melloware, Inc.

Version:
4.0
Author:
Emil A. Lefkof III

Constructor Summary
Player()
          Default constructor.
 
Method Summary
 void fadeIn()
          Fades the volume in.
 void fadeOut()
          Fades the volume out.
 long getElapsedTime()
          Gets the elapsedTime.
 JukesPlayer getPlayer()
          Gets the player.
 int getStatus()
           
 float getVolume()
          Gets the volume.
 void opened(java.lang.Object stream, java.util.Map properties)
          Open callback, stream is ready to play.
 void pause()
          Pause if playing, play if paused.
 void play()
          Plays the file located at filename.
 void play(java.lang.String filename)
          Plays the file located at filename.
 void progress(int bytesread, long microseconds, byte[] pcmdata, java.util.Map properties)
          Progress callback while playing.
 void resume()
          Stop the currently playing song.
 void seek(float aPosition)
          Seeks to a position in the song.
 void setController(javazoom.jlgui.basicplayer.BasicController controller)
          A handle to the BasicPlayer, plugins may control the player through the controller (play, stop, ...)
 void setVolume(float aVolume)
           
 void stateUpdated(javazoom.jlgui.basicplayer.BasicPlayerEvent event)
          Notification callback for basicplayer events such as opened, eom ...
 void stop()
          Stop the currently playing song.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Player

public Player()
Default constructor.

Method Detail

getPlayer

public JukesPlayer getPlayer()
Gets the player.

Returns:
Returns the player.

getStatus

public int getStatus()
Returns:
the player status

getVolume

public float getVolume()
Gets the volume.

Returns:
Returns the volume.

setController

public void setController(javazoom.jlgui.basicplayer.BasicController controller)
A handle to the BasicPlayer, plugins may control the player through the controller (play, stop, ...)

Specified by:
setController in interface javazoom.jlgui.basicplayer.BasicPlayerListener
Parameters:
controller - : a handle to the player

setVolume

public void setVolume(float aVolume)
               throws java.lang.Exception
Throws:
java.lang.Exception

fadeIn

public void fadeIn()
            throws javazoom.jlgui.basicplayer.BasicPlayerException,
                   java.lang.InterruptedException
Fades the volume in.

Throws:
javazoom.jlgui.basicplayer.BasicPlayerException - if any player error occurs
java.lang.InterruptedException - if any thread error occurs

fadeOut

public void fadeOut()
             throws javazoom.jlgui.basicplayer.BasicPlayerException,
                    java.lang.InterruptedException
Fades the volume out.

Throws:
javazoom.jlgui.basicplayer.BasicPlayerException - if any player error occurs
java.lang.InterruptedException - if any thread error occurs

opened

public void opened(java.lang.Object stream,
                   java.util.Map properties)
Open callback, stream is ready to play. properties map includes audio format dependant features such as bitrate, duration, frequency, channels, number of frames, vbr flag, ...

Specified by:
opened in interface javazoom.jlgui.basicplayer.BasicPlayerListener
Parameters:
stream - could be File, URL or InputStream
properties - audio stream properties.

pause

public void pause()
Pause if playing, play if paused.


play

public void play()
Plays the file located at filename.


play

public void play(java.lang.String filename)
Plays the file located at filename.

Parameters:
filename - the filename to play

progress

public void progress(int bytesread,
                     long microseconds,
                     byte[] pcmdata,
                     java.util.Map properties)
Progress callback while playing. This method is called severals time per seconds while playing. properties map includes audio format features such as instant bitrate, microseconds position, current frame number, ...

Specified by:
progress in interface javazoom.jlgui.basicplayer.BasicPlayerListener
Parameters:
bytesread - from encoded stream.
microseconds - elapsed (reseted after a seek !).
pcmdata - PCM samples.
properties - audio stream parameters.

resume

public void resume()
Stop the currently playing song.


seek

public void seek(float aPosition)
Seeks to a position in the song.

Parameters:
aPosition - the position to seek to

stateUpdated

public void stateUpdated(javazoom.jlgui.basicplayer.BasicPlayerEvent event)
Notification callback for basicplayer events such as opened, eom ...

Specified by:
stateUpdated in interface javazoom.jlgui.basicplayer.BasicPlayerListener
Parameters:
event - the BasicPlayerEvent fired.

stop

public void stop()
Stop the currently playing song.


getElapsedTime

public long getElapsedTime()
Gets the elapsedTime.

Returns:
Returns the elapsedTime.


Copyright © 1999-2008 Melloware Inc. All Rights Reserved.