Section 10.1. Using Sound


10.1. Using Sound

The sound task plays a sound-file at the end of the build according to whether the build failed or succeeded. You can specify one sound file to play, or if you specify a directory, the sound task will randomly select a sound file to play.

If you're using Java 1.3 or later, you need the Java Media Framework on the classpath (javax.sound).


The sound task can contain success and fail elements. The success element specifies the sound you want played if the build succeeds and failures the sound if it fails. Here's an example where the build file specifies the sounds to play depending on if the build succeeded or failed:

<target name="sounds">     <sound>         <success source="${user.home}/sounds/success.wav"/>         <fail source="${user.home}/sounds/noway.wav"/>     </sound> </target>

These success and failure elements support the attributes you see in Table 10-1.

Table 10-1. The success and fail elements' attributes

Attribute

Description

Required

Default

source

Specifies the name of a sound file

Yes

 

loops

Specifies the number of times to play the sound file

No

0

duration

Specifies the time (measured in milliseconds) you want to play the sound file

No

 




    Ant. The Definitive Guide
    Ant: The Definitive Guide, 2nd Edition
    ISBN: 0596006098
    EAN: 2147483647
    Year: 2003
    Pages: 115
    Authors: Steve Holzner

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net