You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sound.html 4.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Sound Task</title>
  20. </head>
  21. <body>
  22. <h2 id="sound">Sound</h2>
  23. <h3>Description</h3>
  24. <p>Plays a sound file at the end of the build, according to whether the build failed or
  25. succeeded. You can specify either a specific sound file to play, or, if a directory is specified,
  26. the <code>&lt;sound&gt;</code> task will randomly select a file to play. <strong>Note</strong>: At
  27. this point, the random selection is based on all the files in the directory, not just those ending
  28. in appropriate suffixes for sound files, so be sure you only have sound files in the directory you
  29. specify.</p>
  30. <p>More precisely <code>&lt;sound&gt;</code> registers a hook that is triggered when the build
  31. finishes. Therefore you have to place this task as top level or inside a target which is always
  32. executed.</p>
  33. <p>Unless you are running on Java 1.3 or later, you need the Java Media Framework on the classpath
  34. (<code class="code">javax.sound</code>).</p>
  35. <h3>Parameters specified as nested elements</h3>
  36. <h4>success</h4>
  37. <p>Specifies the sound to be played if the build succeeded.</p>
  38. <h4>fail</h4>
  39. <p>Specifies the sound to be played if the build failed.</p>
  40. <h4>Nested element parameters</h4>
  41. <p>The following attributes may be used on the <code>&lt;success&gt;</code>
  42. and <code>&lt;fail&gt;</code> elements:</p>
  43. <table class="attr">
  44. <tr>
  45. <th scope="col">Attribute</th>
  46. <th scope="col">Description</th>
  47. <th scope="col">Required</th>
  48. </tr>
  49. <tr>
  50. <td>source</td>
  51. <td>the path to a sound file directory, or the name of a specific sound file, to be played. If
  52. this file does not exist, an error message will be logged.</td>
  53. <td>Yes</td>
  54. </tr>
  55. <tr>
  56. <td>loops</td>
  57. <td>the number of extra times to play the sound file.</td>
  58. <td>No; default is <q>0</q></td>
  59. </tr>
  60. <tr>
  61. <td>duration</td>
  62. <td>the amount of time (in milliseconds) to play the sound file.</td>
  63. <td>No</td>
  64. </tr>
  65. </table>
  66. <h3>Examples</h3>
  67. <p>Play the <samp>bell.wav</samp> sound file if the build succeeded, or the <samp>ohno.wav</samp>
  68. sound file if the build failed, three times, if the <code>fun</code> property is set to <q>true</q>.
  69. If the target is a dependency of an "initialization" target that other targets depend on,
  70. the <code>fun.done</code> property prevents the target from being executed more than once.</p>
  71. <pre>
  72. &lt;target name=&quot;fun&quot; if=&quot;fun&quot; unless=&quot;fun.done&quot;&gt;
  73. &lt;sound&gt;
  74. &lt;success source=&quot;${user.home}/sounds/bell.wav&quot;/&gt;
  75. &lt;fail source=&quot;${user.home}/sounds/ohno.wav&quot; loops=&quot;2&quot;/&gt;
  76. &lt;/sound&gt;
  77. &lt;property name=&quot;fun.done&quot; value=&quot;true&quot;/&gt;
  78. &lt;/target&gt;</pre>
  79. <p>Randomly select a sound file to play when the build succeeds or fails.</p>
  80. <pre>
  81. &lt;target name=&quot;fun&quot; if=&quot;fun&quot; unless=&quot;fun.done&quot;&gt;
  82. &lt;sound&gt;
  83. &lt;success source=&quot;//intranet/sounds/success&quot;/&gt;
  84. &lt;fail source=&quot;//intranet/sounds/failure&quot;/&gt;
  85. &lt;/sound&gt;
  86. &lt;property name=&quot;fun.done&quot; value=&quot;true&quot;/&gt;
  87. &lt;/target&gt;
  88. </pre>
  89. </body>
  90. </html>