View | Details | Raw Unified | Return to bug 48637
Collapse All | Expand All

(-)a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java (-3 / +9 lines)
Lines 41-47 Link Here
41
 * This class is designed to be used by any AntTask that requires audio output.
42
 * This class is designed to be used by any AntTask that requires audio output.
42
 *
43
 *
43
 * It implements the BuildListener interface to listen for BuildEvents and could
44
 * It implements the BuildListener interface to listen for BuildEvents and could
44
 * be easily extended to provide audio output upon any specific build events occuring.
45
 * be easily extended to provide audio output upon any specific build events occurring.
45
 *
46
 *
46
 * I have only tested this with .WAV and .AIFF sound file formats. Both seem to work fine.
47
 * I have only tested this with .WAV and .AIFF sound file formats. Both seem to work fine.
47
 *
48
 *
Lines 139-147 Link Here
139
    private void playClip(Clip clip, int loops) {
139
    private void playClip(Clip clip, int loops) {
140
140
141
        clip.loop(loops);
141
        clip.loop(loops);
142
        while (clip.isRunning()) {
142
        do {
143
            // Empty block
143
            try {
144
                long timeLeft = (clip.getMicrosecondLength() - clip.getMicrosecondPosition()) / 1000;
145
                Thread.sleep(timeLeft);
146
            } catch (InterruptedException e) {
147
                // Ignore Exception
144
        }
148
        }
149
        } while (clip.isRunning());
145
    }
150
    }
146
151
147
    private void playClip(Clip clip, long duration) {
152
    private void playClip(Clip clip, long duration) {
Lines 151-156 Link Here
151
        } catch (InterruptedException e) {
156
        } catch (InterruptedException e) {
152
            // Ignore Exception
157
            // Ignore Exception
153
        }
158
        }
159
        clip.stop();
154
    }
160
    }
155
161
156
    /**
162
    /**

Return to bug 48637