HTML5 Audio display only play pause and mute buttons

user1380540 picture user1380540 · Dec 10, 2012 · Viewed 49.7k times · Source

I'm wondering if there's a quick and simple way to style the HTML5 audio element to display what I want. I was wondering if you could turn certain controls on and off, but that doesn't seem to be the case.

I do not want a progress/track bar, or to display the time left. I just want a simple play/pause toggle button, and a mute/unmute toggle button.

That's all! Any ideas?

Answer

Mohd. Umar picture Mohd. Umar · Jun 29, 2013

Use this code it will serve your purpose.

<!DOCTYPE html>
<html>
<body>
 <audio id="player" src="horse.ogg"></audio>
<div>
    <button onclick="document.getElementById('player').play()">Play</button>
    <button onclick="document.getElementById('player').pause()">Pause</button>
    <button onclick="document.getElementById('player').muted=!document.getElementById('player').muted">Mute/ Unmute</button>
</div>
</body>
</html>