Reputation: 91
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!
<body>
<li>
<audio controls>
<source src="./songs/Remember-The-Name.mp3" type="audio/mp3">
</audio>
</li>
<body>
Path to html file :
/User/Desktop/music-app/views/test.html
Path to audio file:
/User/Desktop/music-app/songs/Remember-The-Name.mp3
Upvotes: 4
Views: 37301
Reputation: 1
This worked for me:
Instead of using src in source try to directly put it into the audio tag then it will work:
<audio controls src="E:\Songs\Stellar-Grave.mp3" type="audio/mp3">
</audio>
Upvotes: -1
Reputation: 1
Make sure you link your audio correctly. That is what helped me.
Upvotes: -1
Reputation: 43910
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 ../songs/Remember-The-Name.mp3
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');
<section id="media"></section>
Upvotes: 2
Reputation: 2344
Try this.. It works..
Add ..
to goto previous directory and use type="audio/mpeg"
<body>
<li>
<audio controls>
<source src="../songs/Remember-The-Name.mp3" type="audio/mpeg">
</audio>
</li>
<body>
Upvotes: 4