This works fine in all browsers I've tried (IE v10, Chrome v23, Opera v12, and Firefox v17). However, when I view the same pages in Kindle Fire HD, both audio files (ogg and mp3) play -- one after the other (which is driving me mad). This is not supposed to happen. Anyone have any answers and/or suggestions? Thanks! Happy Holidays....

2 Answers
2

This sounds like a bug in the Kindle Fire browser. If the first source file can be played, the second one should be ignored.

It might be worth changing the order of the source elements (i.e. put MP3 first). I doubt it will make a difference but just in case - could be some strange browser quirk.

Another possibility is a bug with the browser's autoplay implementation. Have you tried removing the autoplay attribute? If that's the problem then you could try using JavaScript's play() method on page load instead.

A more reliable solution is to use JavaScript to detect for codec support. Something like this should work:

HTML:

<audio id="myAudio">
Your browser does not support the audio element.
</audio>

Thanks for the reply. I have tried switching the source order -- which produced the same result. I need the auto-play for this particular project. I will experiment with your JavaScript audio type check, but the straight HTML5 Audio tag would be the preferred method -- and it does work as expected in most standard, HTML5 capable browsers.
–
Tom ArnoneDec 26 '12 at 15:12

Sorry, I couldn't get your code to work. However, code at the following link works perfectly in most standard, HTML5 capable browsers, but not at all in the Kindle Fire HD.... SoundLink Was using in body of script: <script type="text/javascript"> var x=Math.round(Math.random()*2) if (x==0) x=sound1 else if (x==1) x=sound2 else x=sound3 window.onload = x.load(); x.play(); </script>
–
Tom ArnoneDec 26 '12 at 16:17

Strange. I've added a link to a working example of this code to my answer. It works for me in Opera, Firefox and Chrome on desktop, and in Opera Mobile, Mobile Firefox and the default Android browser (2.3). If all else fails, the only other thing I can offer is SoundManager 2: schillmania.com/projects/soundmanager2 Scott Schiller has put in a huge amount of work to get audio playing reliably across different browsers and devices. It's probably overkill for your needs but it could be the only option.
–
tagawaDec 27 '12 at 4:57

I have tried the following HTML in the FireHD7 and it works fine - only one of the audio tags plays.
If you are still having a problem what version Silk browser are you using and is it on the HD7 or HD8.9 device?