<audio loop id="effect" src="/assets/web/audio/effect.mp3"></audio>
<script>document.getElementById('effect').pause();</script>
I stop a playing audio this way, the problem is it ends abruptly in the moment I run the javascript code. It's probably tricky but I wonder how could I stop it but allowing it to complete the playing iteration?
CodePudding user response:
document.getElementById('effect').loop = false;
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loop