com.tuneology.avm.player
Class Player

java.lang.Object
  |
  +--com.tuneology.avm.player.Player
Direct Known Subclasses:
LocalPlayer, QTPlugin

public abstract class Player
extends java.lang.Object

An abstract class for representing a way to play a media file.

Version:
$Id: Player.java,v 1.18 2003/07/10 19:52:12 xnarf Exp $
Author:
Fran Taylor

Field Summary
protected  java.lang.String dev
           
protected  java.util.ArrayList listeners
           
protected  boolean looping
           
 
Constructor Summary
protected Player(java.lang.String dev, java.lang.String name)
           
 
Method Summary
 void addStatusListener(PlayerStatusListener ps)
          Adds a PlayerStatus listener to the listener list.
static java.lang.Class findPlayerClass(java.lang.String className)
          Returns the player class, given its class name.
static java.lang.Class findVideoPlayerClass(java.lang.String className)
          Returns the video player class, given its class name.
protected static java.lang.String formatSeconds(long secs)
           
static java.lang.String[] getAudioDevices()
           
static java.lang.Class[] getAudioPlayers()
          Returns an array of all the audio players available on the platform.
abstract  java.awt.Component getCanvas()
           
static java.lang.String getDescription(java.lang.Class cl)
          Returns a string describing the player class.
 java.lang.String getDevice()
           
static java.lang.String getDeviceDescription(java.lang.String dev)
          Returns a string describing the device.
 boolean getLoop()
          Returns true if the player will restart the file from the beginning when it ends.
 java.lang.String getName()
           
static java.lang.String getVersions()
          Returns a string containing the version numbers of all the installed players.
static java.lang.Class[] getVideoPlayers()
          Returns a list of all the video players available on the platform.
protected  void initInstance()
           
static MediaPlayer newMediaPlayer(java.lang.String dev, java.lang.Class cl, java.lang.String name)
          Returns a new instance of a player object, based on its class.
 void removeStatusListener(PlayerStatusListener ps)
          Removes a PlayerStatus listener to the listener list.
 void setDevice(java.lang.String d)
           
 void setLoop(boolean l)
          Set to true, and the file will start playing again when it finishes.
protected abstract  void shutdown()
           
static void shutdownPlayers()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

looping

protected boolean looping

listeners

protected java.util.ArrayList listeners

dev

protected java.lang.String dev
Constructor Detail

Player

protected Player(java.lang.String dev,
                 java.lang.String name)
Parameters:
dev -  
Method Detail

initInstance

protected void initInstance()
                     throws java.lang.Exception

getCanvas

public abstract java.awt.Component getCanvas()

addStatusListener

public void addStatusListener(PlayerStatusListener ps)
Adds a PlayerStatus listener to the listener list.
Parameters:
ps -  

removeStatusListener

public void removeStatusListener(PlayerStatusListener ps)
Removes a PlayerStatus listener to the listener list.
Parameters:
ps -  

setLoop

public void setLoop(boolean l)
Set to true, and the file will start playing again when it finishes.
Parameters:
l -  

getLoop

public boolean getLoop()
Returns true if the player will restart the file from the beginning when it ends.
Returns:
true if the player will restart the file from the beginning when it ends.

getAudioDevices

public static java.lang.String[] getAudioDevices()

getAudioPlayers

public static java.lang.Class[] getAudioPlayers()
Returns an array of all the audio players available on the platform.
Returns:
an array of all the audio players available on the platform.

findVideoPlayerClass

public static java.lang.Class findVideoPlayerClass(java.lang.String className)
Returns the video player class, given its class name. Use this instead of Class.forName(), because java-avm uses custom class loaders for plugins.
Parameters:
className - the name of the desired player class
Returns:
the class whose name is className

findPlayerClass

public static java.lang.Class findPlayerClass(java.lang.String className)
Returns the player class, given its class name. Use this instead of Class.forName(), because java-avm uses custom class loaders for plugins.
Parameters:
className - the name of the desired player class
Returns:
the class whose name is className

getDescription

public static java.lang.String getDescription(java.lang.Class cl)
                                       throws java.lang.Exception
Returns a string describing the player class.
Parameters:
cl -  
Returns:
a string describing the player class.

getDeviceDescription

public static java.lang.String getDeviceDescription(java.lang.String dev)
Returns a string describing the device. TODO: this should be more sophisticated.
Parameters:
dev -  
Returns:
a string describing the device.

getVideoPlayers

public static java.lang.Class[] getVideoPlayers()
Returns a list of all the video players available on the platform.
Returns:
a list of all the video players available on the platform.

newMediaPlayer

public static MediaPlayer newMediaPlayer(java.lang.String dev,
                                         java.lang.Class cl,
                                         java.lang.String name)
                                  throws java.lang.Exception
Returns a new instance of a player object, based on its class.
Parameters:
dev - the name of the sound output device to be used
cl - the class of the media player to instantiate.
Returns:
the new instance.
Throws:
java.lang.Exception -  

getVersions

public static java.lang.String getVersions()
Returns a string containing the version numbers of all the installed players.
Returns:
the version string.

shutdownPlayers

public static void shutdownPlayers()

getName

public java.lang.String getName()

getDevice

public java.lang.String getDevice()

setDevice

public void setDevice(java.lang.String d)
               throws java.lang.Exception

formatSeconds

protected static java.lang.String formatSeconds(long secs)

shutdown

protected abstract void shutdown()