Reputation: 21
I'm trying to create a button which plays and pauses audio when clicked. This works fine in Google Chrome and newer browsers although I need it to support IE 8 as well. I've tried using <embed>
tags and have changed the triggers to fit the embedded audio but it still doesn't play or pause in IE 8? I'd like to use jQuery if possible.
HTML
<audio id="sound" src="sound.mp3"></audio>
JavaScript/jQuery
$(document).ready(function() {
$('.toggle-snd').click(function() {
if ($('#sound').prop("paused") == false) {
$('#sound').trigger("pause");
$('.toggle-snd').text('Play interview');
$('.toggle-snd').toggleClass('active2');
} else {
$('#sound').trigger("play");
$('.toggle-snd').text('Pause interview');
$('.toggle-snd').toggleClass('active2');
}
});
});
Upvotes: 1
Views: 1710