title: Simple captcha audio settings in java
body: <p>I have a form in which I have implemented  <a href="http://simplecaptcha.sourceforge.net/" rel="nofollow noreferrer">Simple captcha</a> every thing is working fine but I want audio captcha to be played when users click on play button. In my case audio gets played default on page load.</p>
  
  <p>Below is my code for audio captcha</p>
  
  <pre><code>public class MyAudioCaptcha extends AudioCaptchaServlet {
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {
      try {
  
          MyTextProducer myTextProducer  = (MyTextProducer) req.getSession().getAttribute("myTextProducer");
          if(myTextProducer == null){
              myTextProducer = new MyTextProducer();
  
          }
          AudioCaptcha ac = new AudioCaptcha.Builder().
                  addAnswer(myTextProducer).
                  addNoise().
                  build(); // Required
  
                  CaptchaServletUtil.writeAudio(resp, ac.getChallenge());
                  req.getSession().setAttribute("audioCaptcha", ac);
      } catch (Exception e) {
          Util.AppendExceptionToLog(e);
      }
  
    }
  }
  </code></pre>
  
  <p>JSP code:</p>
  
  <pre><code>   &lt;script&gt;
          $(document).ready(function(){
              reloadCaptcha();
          });
        function reloadCaptcha(){
          var d = new Date();
          $.ajax({
            url:"captcha.jsp",
            type :"POST",
            async:true,
            data: { 
              'action':  'generateCaptcha' ,
            },
          success:function(response){
             $("#captcha_image").attr("src", "../../simpleCaptcha.png?"+d.getTime());
             $("#captcha_audio").attr("src", "../../audio.wav?"+d.getTime());
  
           },
       });    
  
      }
     &lt;/script&gt;
  &lt;body&gt;
      &lt;td&gt;
       &lt;div class="inputfield" style="margin-left: 10px;"&gt;
          &lt;img  id="captcha_image" /&gt; 
          &lt;img  src="../../images/reload.jpg" onclick="reloadCaptcha()" style="cursor: pointer;" alt="reload"width="30" height="30"/&gt;
      &lt;/div&gt;
     &lt;/td&gt;
     &lt;td&gt;
          &lt;audio controls autoplay  id="captcha_audio" autoplay = "false"&gt;&lt;/audio&gt;
     &lt;/td&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Is there any configurable in above code so that audio do not play on page load, to be played only if user click on audio captcha <a href="https://i.stack.imgur.com/wJllY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wJllY.jpg" alt="enter image description here"></a></p>