JmC
JmC

Reputation: 21

Audio tag alternatives for IE8

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

Answers (1)

icaru12
icaru12

Reputation: 1582

You could use audio.js, a cross-browser javascript wrapper for the html5 audio tag.

Upvotes: 1

Related Questions