Horje
How to set HTML <audio> Autoplay

To start an audio file automatically, use the autoplay attribute:


Example of HTML Audio Autoplay

Follow the Example
index.html
Example: HTML
 <audio controls autoplay>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio> 

Output should be:

Example of HTML Audio Autoplay

Full Example of HTML Audio Autoplay

Follow the Example
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<audio controls autoplay>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

Full Example of HTML Audio Autoplay

Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.
Reffered: https://www.w3schools.com/html/html5_audio.asp





Related Articles
What is HTML Audio HTML Audio
How It Works HTML Audio HTML Audio
How to set HTML <audio> Autoplay HTML Audio
How to Add muted after autoplay HTML Audio
What are the HTML Audio Formats HTML Audio
What are the HTML Audio - Media Types HTML Audio
What are the HTML Audio - Methods, Properties, and Events HTML Audio

Single Articles
Example of HTML Audio AutoplayHTML Audio
Full Example of HTML Audio AutoplayHTML Audio

Read Full:
HTML Audio
Category:
Web Tutorial
Sub Category:
HTML Audio
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
34



Share on: