I am struggling a bit with this one.
I am uploading music to our server, which works fine. When I play the song, it plays and stops just fine.
But when I upload a new song with the same name, I play the song directly from the server and I can hear that it is the new song, but when I play the song with jQuery, it still plays the old song.
My code for the music is as follows:
HTML
<span id="toggle_<?= $number; ?>_music" class="badge play_music" style="background-color: green; cursor: pointer;" onclick="sadsc_play_entry_music('<?= $number; ?>')">
<audio id="entry_<?= $entry['location_entry_id']; ?>_music">
<source src="comps/sadsc/music/<?= $location; ?>/<?= $number; ?>.<?= $extention; ?>" />
</audio>
</span>
JS
function sadsc_play_entry_music(entry_id)
{
file = "#entry_"+entry_id+"_music";
var player = $(file)[0];
if (!player.paused)
{
player.pause();
player.currentTime = 0;
$('#toggle_'+entry_id+'_music').css('background-color', 'green');
$('#toggle_'+entry_id+'_music i').removeClass('fa-stop').addClass('fa-play');
}
else
{
all_audio = $('audio');
all_audio.each(function( index ) {
all_audio[index].pause();
all_audio[index].currentTime = 0;
});
$('.play_music').css('background-color', 'green');
$('.play_music i').removeClass('fa-stop').addClass('fa-play');
player.play();
$('#toggle_'+entry_id+'_music').css('background-color', 'orange');
$('#toggle_'+entry_id+'_music i').removeClass('fa-play').addClass('fa-stop');
}
}
I have tried
player.load();
to reload the file, but that did nothing.
Thanx in advance