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.2 KiB

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