FileDocCategorySizeDatePackage
SoundTask.javaAPI DocApache Ant 1.706022Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.optional.sound

SoundTask

public class SoundTask extends org.apache.tools.ant.Task
Plays a sound file at the end of the build, according to whether the build failed or succeeded. There are three attributes to be set: source: the location of the audio file to be played duration: play the sound file continuously until "duration" milliseconds has expired loops: the number of times the sound file should be played until stopped I have only tested this with .WAV and .AIFF sound file formats. Both seem to work fine. plans for the future: - use the midi api to define sounds (or drum beat etc) in xml and have Ant play them back

Fields Summary
private BuildAlert
success
private BuildAlert
fail
Constructors Summary
public SoundTask()
Constructor for SoundTask.

    
Methods Summary
public org.apache.tools.ant.taskdefs.optional.sound.SoundTask$BuildAlertcreateFail()
add a sound when the build fails

return
a BuildAlert to be configured

        fail = new BuildAlert();
        return fail;
     
public org.apache.tools.ant.taskdefs.optional.sound.SoundTask$BuildAlertcreateSuccess()
add a sound when the build succeeds

return
a BuildAlert to be configured


                      
       
        success = new BuildAlert();
        return success;
    
public voidexecute()
Execute the task.


        AntSoundPlayer soundPlayer = new AntSoundPlayer();

        if (success == null) {
            log("No nested success element found.", Project.MSG_WARN);
        } else {
            soundPlayer.addBuildSuccessfulSound(success.getSource(),
              success.getLoops(), success.getDuration());
        }

        if (fail == null) {
            log("No nested failure element found.", Project.MSG_WARN);
        } else {
            soundPlayer.addBuildFailedSound(fail.getSource(),
              fail.getLoops(), fail.getDuration());
        }

        getProject().addBuildListener(soundPlayer);

    
public voidinit()
Initialize the task.