🥓's profile picture

Published by

published
updated

Category: Web, HTML, Tech

How to import/host music/audio for profile/blog/bulletin (VIDEO) *no longer works*


Autoplay without displaying player/controls

<div style="display:none">
<audio controls="0" autoplay="1">
  <source src="URL to MP3.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</source></audio></div>

This code will basically have an audio file play, but have it hidden. In my case its only an audio clip that goes for 5 seconds. But if you have music you may want to be nice and have a tiny player so people can stop the audio on your page (up to you, I don't care, others can though).

Autoplay with player/controller

If you want to have a player displaying (its quite small and compact) simply remove the div part of the code so it looks like this (to remove autoplay remove the autoplay completely):

<audio controls="1" autoplay="1">
  <source src="URL to MP3 file.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</source></audio>


17 Kudos

Comments

Displaying 0 of 0 comments ( View all | Add Comment )