There are websites that have autoplay features along with other elements. This makes the content of the web page more understandable and some websites essentially require this feature, for instance, if there is a kid learning website, it will require audio features for sure. Audio autoplay in chrome can be easily inserted using HTML markup language through the audio tag. Through this, the user that interacts with the web page can easily hear the audio.
Syntax for audio Tag
Audio autoplay is inserted through the audio tag with the controls autoplay attribute. While writing, simply add an audio tag with controls autoplay attribute and add the source audio file location from the system after src=:
<source src="audio-mp3.mp3" type="audio/mp3">
</audio>
Note: The controls attribute is used to make the audio element visible on the interface and the audio attribute is used to start the audio.
How to Use audio Tag to Autoplay?
The user can insert the audio element anywhere on the interface. For instance, if we want to make an audio autoplay on a blank web page under a simple <h1> heading. To insert an audio autoplay element on a web page:
Audio Autoplay in Chrome
</h1>
<audio controls autoplay>
<source src="audio-mp3.mp3" type="audio/mp3">
</audio>
The above code will create the following output and the audio will be played automatically on loading the web page:
This is how we can create an audio auto play on chrome through a simple HTML audio tag.
Conclusion
Audio auto play can be easily created on chrome through a simple HTML audio tag. All it requires is to add the audio tag with a controls autoplay attribute and then add the location of the source mp3 file from the system inside the audio tag. This displays the audio element on the web page and the audio is played automatically when the web page is loaded. This post explained well how to make audio auto play on chrome.