yakscript.action
Class Play

java.lang.Object
  |
  +--yakscript.Action
        |
        +--yakscript.action.Play
All Implemented Interfaces:
java.util.EventListener, javax.sound.sampled.LineListener

public class Play
extends Action
implements javax.sound.sampled.LineListener

Syntax: Play [-pre] <samples...>
Sets: $RC = YES if successful, NO if failed

Loads and plays sound samples. If -pre is specified, the samples are loaded into memory but not played, allowing faster playback if invoked later. Once loaded, samples stay in memory until the script exits.

Samples are played using the Java Sound API, so supported sample formats are limited by the Java installation in use. One safe option that should work anywhere is PCM (unsigned) WAV. Note that Play assumes that all samples used in one invocation are in the same format, so strange things will happen if they are not.


Fields inherited from class yakscript.Action
arguments, condition
 
Constructor Summary
Play()
           
 
Method Summary
 boolean exec(YakScript ys)
          Executes this action
Override this to actually provide the functionality of your action
 java.lang.String getKeyword()
          Return the keyword of this action
 void setArguments(java.util.StringTokenizer _arguments)
          Set the arguments for this action and verify their contents
Override this if you need to perform syntax checking on the arguments passed to your action
 void update(javax.sound.sampled.LineEvent le)
          Called by LineListener when audio events occur.
 
Methods inherited from class yakscript.Action
isCondition, isFinal, isInitial, setCondition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Play

public Play()
Method Detail

getKeyword

public java.lang.String getKeyword()
Description copied from class: Action
Return the keyword of this action
Overrides:
getKeyword in class Action
Following copied from class: yakscript.Action
Returns:
Keyword string

setArguments

public void setArguments(java.util.StringTokenizer _arguments)
                  throws SyntaxErrorException
Description copied from class: Action
Set the arguments for this action and verify their contents
Override this if you need to perform syntax checking on the arguments passed to your action
Overrides:
setArguments in class Action
Following copied from class: yakscript.Action
Parameters:
args - Arguments to pass
Throws:
SyntaxErrorException - Thrown if the arguments are syntactically invalid for this action

exec

public boolean exec(YakScript ys)
Description copied from class: Action
Executes this action
Override this to actually provide the functionality of your action
Overrides:
exec in class Action
Following copied from class: yakscript.Action
Parameters:
yakScript - Currently executing instance of YakScript
Returns:
Whether command execution was successful

update

public void update(javax.sound.sampled.LineEvent le)
Called by LineListener when audio events occur. When a Type.STOP is received, we stop the sample. (Don't blame me, blame the Java Sound API...)
Specified by:
update in interface javax.sound.sampled.LineListener