Nim Nim - 6 months ago 31
HTML Question

How do I /actually/ link mp3 into html?

I've literally just started learning how to use this; kinda unsure on how linking audio files into the script works; All I'm trying to do is have a small audio player, nothing more.

<audio controls width="100" height="100">
<source src="somethin.mp3" type="audio/mp3">
<!-- Fallback for older browsers -->
Your browser doesn't support html5 audio

Answer Source

It all depends on the file location. For your script above you would put your somethin.mp3 in the same location as you html file. If you want to put it in a sub folder (say your folder containing the .mp3 was called audio) it would be <source src="audio/somethin.mp3" type="audio/mp3">. If it was in a second sub folder (say the second was called html_sound) then it would be <source src="audio/html_sound/somethin.mp3" type="audio/mp3">. If you want to go one dictionary up you would use <source src="../somethin.mp3" type="audio/mp3">. Two dictionaries up would be <source src="../../somethin.mp3" type="audio/mp3"> and so on.

Just copy the dictionary name to go into a folder and use ../ to go up one folder.

also your code does not end with </audio> tag (It MUST) and it's type="audio/mpeg" not type="audio/mp3".

Best test the script in Chrome, Edge or Internet Explorer (if you have Windows) are OK too but do not test it in Firefox or Opera as it supports .ogg files (I know W3schools says it does but all you need is an outdated browser and it will not work).

You might want to check this out.

If you have done links or images they are exactly the same.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download