'Stop looping audio with javascript but completing playing iteration

<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?



Solution 1:[1]

document.getElementById('effect').loop = false;

https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loop

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brad