I made a simple "play / pause" button for audio, with the following script:
<audio id="myAudio"
src="http://www.sousound.com/music/healing/healing_01.mp3"preload="auto">
</audio>
<script type="text/javascript" charset="utf-8" async defer>
var myAudio = document.getElementById("myAudio");
var isPlaying = false;
function togglePlay() {
if (isPlaying) {
myAudio.pause()
} else {
myAudio.play();
}
};
myAudio.onplaying = function() {
isPlaying = true;
};
myAudio.onpause = function() {
isPlaying = false;
};
</script>
However, I would actually like that by clicking the " play / pause " button instead of pausing, I would restart playback. Any light?