Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading