Jump to content

Can't get HTML audio tags to work

Go to solution Solved by Mira Yurizaki,
1 minute ago, ThatBlockishWay said:

Im still really new to html, can you dumb that down abit? Also all the files for this are going to be local so I didnt know if thatd really matter

An absolute path is the full path name of where something is. What you used is an example an absolute path. Or rather, an absolute path always starts from the root directory, like a drive letter in Windows or from / in Linux or macOS.

 

A relative path starts from where the webpage is located in the storage drive. So if your web page is at D:\Documents\website\example.html, then if you type in "foobar\fizzbuzz\test.mp3" as the path, the browser will look in D:\Documents\website\foobar\fizzbuzz for this file. But if the web page is in C:\Users\Test\Documents\example.html, then it will look in C:\Users\Test\Documents\foobar\fizzbuzz instead. If you need a relative path to go down a level in the directory tree, you use two periods ( .. ). So if the web page is at D:\Documents\website\example.html and the mp3 file is in D:\Documents\resources\test.mp3 , you need to use "..\resources\test.mp3"

<audio controls autoplay loop>
	<source src="C:/Maker/game/test.mp3" type="audio/mpeg"/>
</audio>

 

What about this isn't right? Ive been browsing forums for like a half hour and I cant find anything thatll work, all I want is for the audio to play and loop as the webpage is opened and preferrably also be hidden (theres no audio control visible)

I cant seem to wrap my brain around whats off

Edit: Nevermind it is working but why is it that when I refresh the page unless I wait a bit it doesnt start autoplaying again? (Im using chrome to test this)

Edit-re:I think my issue is something with chrome itself, thanks for the help though!

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Mira Yurizaki said:

You shouldn't be using absolute paths, especially a Microsoft formatted path. The path should be relative to the page itself so it's platform agnostic to how it's resolved.

Im still really new to html, can you dumb that down abit? Also all the files for this are going to be local so I didnt know if thatd really matter

Edit: So I got rid of the pathing (theyre in the same folder so I guiess it doesnt matter?) does that help anything though? Like does the pathing present an issue somehow?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, ThatBlockishWay said:

Im still really new to html, can you dumb that down abit? Also all the files for this are going to be local so I didnt know if thatd really matter

An absolute path is the full path name of where something is. What you used is an example an absolute path. Or rather, an absolute path always starts from the root directory, like a drive letter in Windows or from / in Linux or macOS.

 

A relative path starts from where the webpage is located in the storage drive. So if your web page is at D:\Documents\website\example.html, then if you type in "foobar\fizzbuzz\test.mp3" as the path, the browser will look in D:\Documents\website\foobar\fizzbuzz for this file. But if the web page is in C:\Users\Test\Documents\example.html, then it will look in C:\Users\Test\Documents\foobar\fizzbuzz instead. If you need a relative path to go down a level in the directory tree, you use two periods ( .. ). So if the web page is at D:\Documents\website\example.html and the mp3 file is in D:\Documents\resources\test.mp3 , you need to use "..\resources\test.mp3"

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Mira Yurizaki said:

An absolute path is the full path name of where something is. What you used is an example an absolute path. Or rather, an absolute path always starts from the root directory, like a drive letter in Windows or from / in Linux or macOS.

 

A relative path starts from where the webpage is located in the storage drive. So if your web page is at D:\Documents\website\example.html, then if you type in "foobar\fizzbuzz\test.mp3" as the path, the browser will look in D:\Documents\website\foobar\fizzbuzz for this file. But if the web page is in C:\Users\Test\Documents\example.html, then it will look in C:\Users\Test\Documents\foobar\fizzbuzz instead. If you need a relative path to go down a level in the directory tree, you use two periods ( .. ). So if the web page is at D:\Documents\website\example.html and the mp3 file is in D:\Documents\resources\test.mp3 , you need to use "..\resources\test.mp3"

That wouldve saved me so much typing.... +dies alittle on the inside+ Good to note though, but after changing the pathing it still seems to not want to work on refreshing the page

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×