There is a list of generated audio elements with a unique id:
<audio class="song" preload="auto" id="id-92" controls="controls"> <source src="../uploads/f2e49d34edc7fd037d2930f8d86552d5.mp3"> </audio> <audio class="song" preload="auto" id="id-93" controls="controls"> <source src="../uploads/f2e49d34edc7fd037d2930f8d86552d5.mp3"> </audio> I found the following code on stackoverflow.com javascript:
$(function(){ $('audio').on('play', function() { $('audio').not(this).each(function(index, audio) { audio.pause(); }); }); It allows you to stop the currently played audio item if another audio item starts playing. Tell me how it can be improved, so that at the end of the playback of one, the next one will play?