audio and sourse | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

audio and sourse

"There are two different ways to specify the audio source file's URL" How do I choose which one to use?

13th Jul 2018, 10:05 AM
Alessandra C
Alessandra C - avatar
3 Answers
+ 5
Hello, Alessandra C ! The path to the file is specified via the src attribute or a nested <source> tag. Inside the <audio> container, you can write text that will be displayed in browsers that do not work with this tag. For universal playback in specified browsers, audio is encoded using different codecs and files are added simultaneously through the <source> tag. It's best to upload your sound file to any hosting that supports audio files, then copy the full link with the extension .mp3, ogg, and the others. Also you can pay attention to one of the lessons of SoloLearn. Good luck! https://www.sololearn.com/learn/HTML/2193/?ref=app
13th Jul 2018, 10:20 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 3
It's cleaner if you only have one audio file to use the first method. I usually use the second method for backup file types.
13th Jul 2018, 10:13 AM
Janningā­
Janningā­ - avatar
+ 3
Hi @Alexander Sokolov, Thanks for your explanation. So basically I can use source either as an element or an attribute, is quite the same, isn't? In both case I need to use the extension .mp3 (or other), but only when I have to put an alert text I should use the <audio> </audio> tags. (That is for me, to be more clear(?))
13th Jul 2018, 10:41 AM
Alessandra C
Alessandra C - avatar