audio play in template

               function myAudioFunction(img) {
                       var curAudios= new Audio("{{ model.audio.url }}");
                       curAudios.play();
               }

after I triggered this audio, how do I know it is running, if I need to trigger another audio, I need to stop this one first. it return null or below code. please help!

var vid = document.getElementById(curAudios.id);

This is not really a Django question, which is probably the reason for the current lack of answers – a more frontend-focused/JavaScript community would probably be better suited to help you.

From reading the documentation on HTMLMediaElement (which is the base type behind audio and video elements), I’d assume that you can check the paused attribute.

You should probably save your currently running audio element to a (global) variable. Additionally, register an event handler on all audio elements’ play event, which checks if there is currently audio running, and stops the running audio if needed.