## org.apache.tools.ant.taskdefs.optional.sound
Class AntSoundPlayer

    java.lang.Object
      org.apache.tools.ant.taskdefs.optional.sound.AntSoundPlayer

All Implemented Interfaces:
  BuildListener, java.util.EventListener, javax.sound.sampled.LineListener

public class AntSoundPlayer
extends java.lang.Object
implements javax.sound.sampled.LineListener, BuildListener

This class is designed to be used by any AntTask that requires audio output. It implements the BuildListener interface to listen for BuildEvents and could be easily extended to provide audio output upon any specific build events occuring. I have only tested this with .WAV and .AIFF sound file formats. Both seem to work fine.

Version:
  $Revision: 1.9.2.1 $, $Date: 2003/02/10 14:25:19 $
Author:
  Nick Pellow

Constructor Summary
`AntSoundPlayer()`

Method Summary
`void` `addBuildFailedSound(java.io.File fileFail, int loopsFail, java.lang.Long durationFail)`
`void` `addBuildSuccessfulSound(java.io.File file, int loops, java.lang.Long duration)`
`void` `buildFinished(BuildEvent event)` Fired after the last target has finished.
`void` `buildStarted(BuildEvent event)` Fired before any targets are started.
`void` `messageLogged(BuildEvent event)` Fired whenever a message is logged.
`void` `targetFinished(BuildEvent event)` Fired when a target has finished.
`void` `targetStarted(BuildEvent event)` Fired when a target is started.
`void` `taskFinished(BuildEvent event)` Fired when a task has finished.
`void` `taskStarted(BuildEvent event)` Fired when a task is started.
`void` `update(javax.sound.sampled.LineEvent event)` This is implemented to listen for any line events and closes the clip if required.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AntSoundPlayer

    public AntSoundPlayer()

Method Detail

### addBuildSuccessfulSound

    public void addBuildSuccessfulSound(java.io.File file,
                                        int loops,
                                        java.lang.Long duration)

  Parameters:
    `loops` - the number of times the file should be played when the build is successful
    `duration` - the number of milliseconds the file should be played when the build is successful

### addBuildFailedSound

    public void addBuildFailedSound(java.io.File fileFail,
                                    int loopsFail,
                                    java.lang.Long durationFail)

### update

    public void update(javax.sound.sampled.LineEvent event)

  This is implemented to listen for any line events and closes the clip if required.

  Specified by:
    `update` in interface `javax.sound.sampled.LineListener`

### buildStarted

    public void buildStarted(BuildEvent event)

  Fired before any targets are started.

  Specified by:
    `buildStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.

### buildFinished

    public void buildFinished(BuildEvent event)

  Fired after the last target has finished. This event will still be thrown if an error occured during the build.

  Specified by:
    `buildFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getException()`

### targetStarted

    public void targetStarted(BuildEvent event)

  Fired when a target is started.

  Specified by:
    `targetStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getTarget()`

### targetFinished

    public void targetFinished(BuildEvent event)

  Fired when a target has finished. This event will still be thrown if an error occured during the build.

  Specified by:
    `targetFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getException()`

### taskStarted

    public void taskStarted(BuildEvent event)

  Fired when a task is started.

  Specified by:
    `taskStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getTask()`

### taskFinished

    public void taskFinished(BuildEvent event)

  Fired when a task has finished. This event will still be throw if an error occured during the build.

  Specified by:
    `taskFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getException()`

### messageLogged

    public void messageLogged(BuildEvent event)

  Fired whenever a message is logged.

  Specified by:
    `messageLogged` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getMessage()`, `BuildEvent.getPriority()`

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.