how to add audio file in html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to add audio file in html

5th Dec 2020, 7:18 PM
Sagar Jamaria
Sagar Jamaria - avatar
2 Answers
+ 1
The audio element creates an audio player inside the browser The below audio tags play the same audio file but can be written in two ways <audio controls source src="http://www.sololearn.com/uploads/audio.mp3" type="audio/mpeg"> Audio File not supported by browser </audio> <audio controls> <source src="http://www.sololearn.com/uploads/audio.mp3" type="audio/mpeg"> Audio File not supported by browser <!--This text will be displayed if the user's browser does not support the file format--> </audio> You can use Audio Attributes: *Controls - Specifies that audio controls should be displayed (such as a play/pause button, etc). *Autoplay - When this attribute is defined, audio starts playing as soon as it is ready. Without asking for the visitor's permission. Which can be very unpleasant experience for users, so should be avoided when possible. *Loop - This attribute is used to have the audio replay every time it finishes. https://code.sololearn.com/WC0CGPvL3X2O/#html Hope it is helpful. Regards,
5th Dec 2020, 8:25 PM
Abdul Rahman N
Abdul Rahman N - avatar