Class AntSoundPlayer

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

    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 occurring. I have only tested this with .WAV and .AIFF sound file formats. Both seem to work fine.
    • Constructor Detail

      • AntSoundPlayer

        public AntSoundPlayer()
    • Method Detail

      • addBuildSuccessfulSound

        public void addBuildSuccessfulSound​(java.io.File file,
                                            int loops,
                                            java.lang.Long duration)
        Parameters:
        file - the location of the audio file to be played when the build is successful
        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)
        Parameters:
        fileFail - the location of the audio file to be played when the build fails
        loopsFail - the number of times the file should be played when the build is fails
        durationFail - the number of milliseconds the file should be played when the build fails
      • 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
        Parameters:
        event - the line event to follow
      • buildStarted

        public void buildStarted​(BuildEvent event)
        Fired before any targets are started.
        Specified by:
        buildStarted in interface BuildListener
        Parameters:
        event - ignored
      • buildFinished

        public void buildFinished​(BuildEvent event)
        Fired after the last target has finished. This event will still be thrown if an error occurred during the build.
        Specified by:
        buildFinished in interface BuildListener
        Parameters:
        event - the build finished event.
        See Also:
        BuildEvent.getException()