All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class guinea.player.VirtualPlayer

java.lang.Object
   |
   +----guinea.player.VirtualPlayer

public class VirtualPlayer
extends Object
implements AudioPlayer, PlayerMessageListener
Virtual player class for SoundPlayer class. A virtual player uses a subset of the channels in the soundplayer.

See Also:
SoundPlayer

Method Index

· addPlayerListener(PlayerListener)
Adds the specified player listener to receive events from this player.
· getAudioDevice()
Get the audio device name.
· getChannels()
Get number of channels is this virtual player.
· getOutputVolume()
Get the output volume level of the player.
· getParentPlayer()
Get the parent player of a virtual player.
· getPlayerDirectory()
Get the directory of the player.
· getPlayerID()
The player ID string of this player.
· getSampleRate()
Get sample rate of player.
· getStartChannel()
Get the starting channel of this virtual player.
· getTempMessageID()
Get a temporary ID string for loading samples etc.
· getVirtualPlayerID()
The player ID string of this player.
· hasAudio()
Does this player support audio?.
· hasVideo()
Does this player support video?.
· isPlayerRunning()
Is the player running? Virtual player is running when the parent is running.
· isVirtualPlayer()
Is the player a 'virtual' player.
· processPlayerMessage(String, String, CommandTokenizer)
This method is invoked when a message is received for this listener.
· registerPlayerObject(String, PlayerMessageListener)
Register a new player object (usually a sample) for receiving messages.
· removePlayerListener(PlayerListener)
Removes the specified player listener so that it no longer receives events from this player.
· sendMessage(String)
Send a message to the player process.
· setAudioDevice(String)
Set audio device to be used.
· setChannels(int)
Set number of channels.
· setOutputVolume(Volume)
Set the output volume level of this virtual player.
· setPlayerDirectory(File)
Set the directory for the player.
· setPlayerID(String)
Set player ID.
· setSampleRate(double)
Set output sample rate.
· startPlayer()
Start the sound player.
· stopPlayer()
Stop the sound player process.
· toString()
Get a string representation of this object.
· unregisterPlayerObject(String)
Remove a player object from player.

Methods

· getAudioDevice
 public String getAudioDevice()
Get the audio device name. It returns the parent's audio device's name.

Returns:
The name of the device or null if no device name has been set.
· setAudioDevice
 public void setAudioDevice(String devname)
Set audio device to be used. Not used in virtual players. Trying to set the device in virtual player will throw a runtime exception.

Parameters:
devname - The name of the device.
· setSampleRate
 public void setSampleRate(double sampleRate)
Set output sample rate. Not used in virtual players. Trying to set the sample rate in virtual player will throw a runtime exception.

Parameters:
sampleRate - The sample rate in Hz.
· getSampleRate
 public double getSampleRate()
Get sample rate of player. This will return the sample rate of the parent player.

Returns:
sample rate in Hz.
· getChannels
 public int getChannels()
Get number of channels is this virtual player.

Returns:
number of channels.
· setChannels
 public void setChannels(int numChannels)
Set number of channels. Not used in virtual players. Trying to set the number of channels in virtual player will throw a runtime exception.

Parameters:
numChannels - Number of channels.
· getStartChannel
 public int getStartChannel()
Get the starting channel of this virtual player.

Returns:
Index of start channel relative to master's device.
· setOutputVolume
 public void setOutputVolume(Volume volume)
Set the output volume level of this virtual player. The volume affects all samples and channels that use this virtual player.

Parameters:
volume - the output volume level. If null, volume 1.0 (linear) will be used.
· getOutputVolume
 public Volume getOutputVolume()
Get the output volume level of the player.

Returns:
the output volume level of player.
· hasAudio
 public boolean hasAudio()
Does this player support audio?.

Returns:
true if audio is supported.
· hasVideo
 public boolean hasVideo()
Does this player support video?.

Returns:
true if video is supported.
· registerPlayerObject
 public void registerPlayerObject(String id,
                                  PlayerMessageListener sample)
Register a new player object (usually a sample) for receiving messages. The player will then know where to send the message from the player. Virtual player simply forwards this registeration to the parent player.

Parameters:
id - a string used to identify this listener.
sample - the listener that wants to receive messages.
· unregisterPlayerObject
 public Object unregisterPlayerObject(String id)
Remove a player object from player.

Parameters:
id - the id of the object to be removed.
Returns:
the removed object or null if no object was found with the given id.
· sendMessage
 public void sendMessage(String msg) throws IOException, PlayerException
Send a message to the player process. Virtual player will simply forward this to the parent player for sending the message.

Parameters:
msg - the message.
Throws: IOException
if some kind of IO exception occurs when talking to the player process.
Throws: PlayerException
an exception occurs with a player.
· isVirtualPlayer
 public boolean isVirtualPlayer()
Is the player a 'virtual' player. A virtual player is a player which uses a parent player and uses only a subset of all output channels for output.

Returns:
this a virtual player so true is always returned.
See Also:
getParentPlayer
· getParentPlayer
 public Player getParentPlayer()
Get the parent player of a virtual player. A parent of a virtual player is usually the real player.

Returns:
the parent player of the virtual player. If a virtual player has no parent, null is returned.
See Also:
isVirtualPlayer
· getVirtualPlayerID
 public String getVirtualPlayerID()
The player ID string of this player. It is usually used to specify which virtual player the command applies to.

Returns:
a player ID string.
· setPlayerID
 public void setPlayerID(String playerID)
Set player ID. Usually, this ID is used to refer to this player or virtual player in the GP test engine.

Parameters:
playerID - A player ID.
· getPlayerID
 public String getPlayerID()
The player ID string of this player.

Returns:
a player ID string.
· getTempMessageID
 public String getTempMessageID()
Get a temporary ID string for loading samples etc. A virtual player will ask temporary IDs from it's parent.

Returns:
an unique temporary ID string that can be used with this player.
· addPlayerListener
 public void addPlayerListener(PlayerListener l)
Adds the specified player listener to receive events from this player.

Parameters:
l - the player listener.
· removePlayerListener
 public void removePlayerListener(PlayerListener l)
Removes the specified player listener so that it no longer receives events from this player.

· startPlayer
 public void startPlayer() throws Exception
Start the sound player. It is usually done automatically when the virtual player is created so this should not be called manually.

Throws: Exception
if an error occurs when trying to start the player, an exception will be thrown.
· stopPlayer
 public void stopPlayer()
Stop the sound player process.

· isPlayerRunning
 public boolean isPlayerRunning()
Is the player running? Virtual player is running when the parent is running.

Returns:
true if player is running, false if not running.
· processPlayerMessage
 public void processPlayerMessage(String targetID,
                                  String command,
                                  CommandTokenizer msg)
This method is invoked when a message is received for this listener.

Parameters:
targetID - the ID of the object this is for.
command - the command string.
msg - The entire message that was received from the player.
· setPlayerDirectory
 public void setPlayerDirectory(File dir)
Set the directory for the player. Player directory can be used to load files from sample directories with relative names. If null is used as the directory, parent player's directory will be used.

Parameters:
dir - A directory.
· getPlayerDirectory
 public File getPlayerDirectory()
Get the directory of the player. Player directory can be used to load files from sample directories with relative names. If virtual player's directory is set to null, the parent player's directory is used.

Parameters:
return - Player directory.
· toString
 public String toString()
Get a string representation of this object.

Returns:
a string.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index