Ricardo Cunha
Ricardo Cunha

Reputation: 2075

autoplay a wav file on html code

I want autoplay a wav file on html code. I find this options on internet:

Don´t work on any browser, but is reported that working:

<object type="audio/x-wav" data="http://www.hydrotoys.com/wavs/Beavis_cornholio.wav" width="320" height="260">
<param name="autostart" value="true" />
<param name="controller" value="true" />
<param name="src" value="http://www.hydrotoys.com/wavs/Beavis_cornholio.wav">
</object>

work on chrome, IE if Windows Media Player installed, for firefox need manual install for wmp player

<embed src="http://www.hydrotoys.com/wavs/Beavis_cornholio.wav" hidden="false" autostart="true" loop="false">

html5 solution,work on chrome, I get this solution on mozilla site, but don´t work on IE.

<audio src="http://www.hydrotoys.com/wavs/Beavis_cornholio.wav" type="audio/x-wav" controls autoplay="autoplay">
<p>Your browser does not support the audio element </p>
<source src="http://www.hydrotoys.com/wavs/Beavis_cornholio.wav"/> 
</audio>

I use a fixed wav on this examples, but I use this code is used for generate my audion on my Servlet


            response.setDateHeader("Expires", 0);
            response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
            response.setHeader("Pragma", "no-cache");
            response.setContentType("audio/x-wav");
            response.setContentLength(byteAudio.length);

Any help?

Upvotes: 2

Views: 21411

Answers (1)

Venkata Krishna
Venkata Krishna

Reputation: 4305

Autoplay of wav audio using html5

<!DOCTYPE html>
 <html>
 <body>

 <audio controls="controls" autoplay="autoplay">
   <source src="horse.ogg" type="audio/ogg">
   <source src="horse.wav" type="audio/mpeg">
   Your browser does not support the audio element.
 </audio>

</body>
</html>

Upvotes: 5

Related Questions