Answer the question
In order to leave comments, you need to log in
How to automatically leave the previous song playing when listening to a new one?
I want to display several audio players on one page, I output each song like this:
<audio id="sound" src="http://dump.bitcheese.net/files/wikamax/shik.mp3" preload="none" controls></audio>
Answer the question
In order to leave comments, you need to log in
jQuery
<script>
$(function() {
$('audio').on('play', function() {
$('audio').addClass('stoped').removeClass('playing');
$(this).removeClass('stoped').addClass('playing');
$('.stoped').each(function() {
$(this).trigger('pause');
$(this)[0].currentTime = 0;
})
})
})
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question