I have music stored in a separate folder that I am trying to play, however the music won't play. Any idea why? All help is appreciated and thanks in advance. Also trying to do the same thing in Jade so if you guys tell me the code for that, it would be great too!
<source src="./songs/Remember-The-Name.mp3" type="audio/mp3">
You can dynamically generate an audio player, I believe your problem is getting the correct path to your mp3. Use this code and change the src value on line 6.
When in doubt, use the absolute path or in your case a relative path of
var audio = document.createElement('audio'); var source = document.createElement('source'); var media = document.getElementById('media'); media.appendChild(audio); audio.appendChild(source); source.setAttribute('src', 'https://glpro.s3.amazonaws.com/_util/smpte/111.mp3'); source.setAttribute('type', 'audio/mpeg'); audio.setAttribute('controls', 'controls');