Ask coding questions

← Back to all posts
How do you get a audio file to play in the index.html?
Dominicl645

i am collaborating with another repl.it user and i am wondering how you would get a audio file to play in the index.html.
where would i have to go and what would i code to get the audio to play?

Voters
SavageSpray
AnimeLover1069
cookieartist350
RedPandaCode
Dominicl645
Comments
hotnewtop
RYANTADIPARTHI

Try this code:

So now, all you have to do is click on the 3 dots, and get your file. And it makes a new file. Just take the name of the file and put it in the play:

That should work

Dominicl645

so this python code will work in HTML? @RYANTADIPARTHI

RYANTADIPARTHI

@dominicl645 uhh, no. If you are doing this in HTML, do it this way:

And for the file name, do the same thing, for the HTML, just click on three dots, and all.

Dominicl645

anyone know how to do this? pls help me

RedPandaCode

To get an audio file you simply need to use an <audio> tag. In side the tag you can give it a "src" attribute with the url of the audio!

RedPandaCode

You can also add a "controls" attribute after "src"

Dominicl645

how would i use that code on a mp3 file already uploaded into the replit? @RedPandaCode

RedPandaCode

@dominicl645 Hmmm... I haven't done that before. Perhaps in "src" you may need to use the file name in repl rather than the URL

Dominicl645

ok i'll try it. @RedPandaCode

RedPandaCode

@dominicl645 Hopefully it works!

Dominicl645

hopefully. @RedPandaCode

Dominicl645

ok it wont play. @RedPandaCode

RedPandaCode

@dominicl645 This is what an audio should look like. See if it helps.

(Also make sure that your volume is turned up)

RedPandaCode

If this does not appear your code may be wrong somehow.
(This was made using the "controls" attribute)

RedPandaCode

Since you uploaded the file into repl, if nothing else works, try swapping the "src" attribute for an "href" attribute

xxpertHacker
littlepenguin