I'm making an audio player script that changes the src=""
of the <audio>
tag, I don't like doing because I'm not doing tracks.
The user clicks on this link:
<a href="#play" onclick="playAudio('song.mp3');">Play</a>
Then this receives the function:
function playAudio(file)
{
var audio = file;
}
if(audio !== '') {
document.getElementById('player').src = 'music/'+audio;
}
else {
}
For this player:
<audio id="player" src="" controls></audio>
I've tried changing different things about the script but it's no good.
Why won't it change the audio?