Search code examples
htmlhtml5-audio

Mozilla doesn't refresh the audio tag file. Mozilla's faulty audio


I have a code that auto-generates captcha image by calling a servlet and displays it in an HTML form. But for the visually impaired I wanted to put an audio file as well. So I store the captcha code generated by the servlet as a session attribute in String form and from that attribute again generate an audio file according to the captcha. So lets say if captcha is "c-a-t" the audio file is generated accordingly. Now the problem is when I refresh the page in Chrome the captcha image and audio both get refreshed which is ideal but in Mozilla only the image is getting refreshed not the audio file.

    <div class="formRow">
                <div class="field">
                    <img style="margin-left:91px; margin-top:-6px;" class="image" src="http:www.xyz.com/captchaServlet"> 
         //the above line calls a servlet for the image       

                </div>
                </div></br>
                 <div class="formRow">
                      <div class="field">
                      <audio style="margin-left:91px;" controls="controls">
      <source  src="http:www.xyz.com/getSound" type="audio/wav">
//the above line calls servlet for audio file
    Your browser does not support this audio format.
    </audio>
                      </div>
             </div>

Solution

  • It could be caching the url. Just use this to make the url unique

    <source  src="http:www.xyz.com/getSound?rand=<?php echo rand(time()); ?>" type="audio/wav">