i have this solution working in chrome:
Play an audio file using jQuery when a button is clicked
but firebug console says:
HTTP "Content-Type" of "audio/mpeg" is not supported. Load of media resource http://path/to/sound.mp3 failed.
is there a way to define both an ogg and mp3 file in this script (assuming this would enable the sound to play in firefox):
<script>
$(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'http://path.com/to/sound.mp3');
$('#play_it').click(function() {
audioElement.play();
});
});
</script>
thank you.
update
i tried just adding another reference to the file below the mp3 reference and it worked, not sure if this is the best solution though:
<script>
$(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'http://path.com/to/sound.mp3');
audioElement.setAttribute('src', 'http://path.com/to/sound.ogg');
$('#play_it').click(function() {
audioElement.play();
});
});
</script>