I was just wondering, what if i wanted to make a project with music in it, what would I need to do to upload the music to the project? Is it even possible to add music to a project on Glitch? Sorry if this sounds like a stupid question, but I’m new to Glitch and not sure how everything is supposed to work…
If you drag and drop the file, it should upload it into assets. Then clicking on it from there will give you a link to it
what do you mean? i just want the music to play in the project when the project is on…not when you click something…
Add this to your script:
Upload the music you want to use on Glitch and copy the link. The fill in the values for your script.
Music is really easy to upload like png and such but you can’t play it by directly viewing unless if they used an iframe
const audio = new Audio("urlhere"); audio.play();
Or if you like one line:
Keep in mind that these days browsers keep an annoying autoplay policy, especially for mobile users. Their browser may be configured so you cannot play audio when the page is loaded, and instead a user gesture may be required to start the audio ex. pressing a button.
Tor does that, right?
You could use the audio tag.
<audio autoplay> <source src="assets link" type="audio/mp3"> Your browser does not support the audio tag. </audio>
thanks! now it works!
You could just do my one liner
<button onclick="var aud=new Audio('url here');aud.play();">hi!</button>
Moved to #coding-help
Feel like this belongs in #glitch-help because he is asking a question directly about Glitch.
yeah, it does, which is why i put it in #glitch-help and not in anywhere else.