Cory's profile picture

Published by

published
updated

Category: Web, HTML, Tech

🖥 Code Snippet: Autoplay Music

Edit Nov 27 2021: This should still work, even with the changes An made to how media works. If it doesn’t, make sure you’ve allowed YouTube access to you on SpaceHey, by going to someone’s page who has a video and allowing access to it.

OK, make a public or unlisted playlist on YouTube and load it with the music you want, then use this code. It is working! Thanks to subfuse for figuring this out! Your playlist can be as long as you'd like, and each song can be as long as you'd like, as far as I can tell.

Caveats: Ad blockers need to be completely off, or at least passing though YouTube and SpaceHey. (But we should be allowing ads on SpaceHey anyway just in case, to support An) In my testing, it works in Safari only when a user clicks on the browser anywhere within like the first second of the page loading. (I'm mulling over how to fix that.) Chrome it works better, Edge it works great. Firefox it may not work at all. It will definitely not work on mobile.

More caveats: YOUR WEB BROWSER NEEDS TO ALLOW AUDIO TO AUTOPLAY! If you go to my profile and don't hear music, then your browser is set to disallow autoplay! 

IF YOU ARE ON SAFARI ON DESKTOP: Preferences ⇢ Websites ⇢ Auto-Play
IF YOU ARE ON CHROME ON DESKTOP: Privacy and Security ⇢ Site Settings ⇢ View Permissions and Date (Below your recent activity) ⇢ Spacehey.com ⇢ Scroll to "Sound" ⇢Click the drop down icon and hit "Allow"


CODE:
<iframe style="opacity:0;position:absolute;pointer-events:none;" frameborder="no" src="https://www.youtube.com/embed/videoseries?list=[YOUR YOUTUBE PLAYLIST ID HERE];&autoplay=1" allowfullscreen=""></iframe></p>


109 Kudos

Comments

Displaying 20 of 31 comments ( View all | Add Comment )

✮ juno ✮

✮ juno ✮'s profile picture

it wont work, i can hear audio from others tho


Report Comment



same issue with me -- i can hear everyone elses music but no matter what code i use it wont work for me

by taun; ; Report

i got mine to work ill give u the code

go to yt, pick a song, press share, press embed, and copy only the bit you see i put there. should work

by ✮ juno ✮; ; Report

oh lmfao the code doesnt show up let me try again

here no spaces

if that doesnt work go to layouts, search hole and scroll till you see "jennifers body autoplay" thats the code i used, replace it w yr own song, if one vid doesnt work pick another

by ✮ juno ✮; ; Report

code again lmfao ok find the layout and replace the song

by ✮ juno ✮; ; Report

hello, can you give me the code please, i dont know how to make it work im so lust, thank you

by ♥ 🌸 usagi pinkberry 🌸 ♥; ; Report

jayjay ( ≧ᗜ≦)

jayjay (  ≧ᗜ≦)'s profile picture

IT WORKED TY <3


Report Comment

Emilio the dirt gardener

Emilio the dirt gardener's profile picture

thank you very much


Report Comment

✮P1tterPeace✮

✮P1tterPeace✮'s profile picture

THANK YOU, YOU ARE A LIFESAVER


Report Comment

3ddcentric

3ddcentric's profile picture

Modern day spacehey hero


Report Comment

undekovr

undekovr's profile picture

thank u ganger !


Report Comment

XxcrestntxX

XxcrestntxX's profile picture

I've tried everything to get this to work with a playlist, I can only get it to work with one song. I'm able to add a playlist but I can't get it to autoplay :( My windows settings have autoplay on and I turned off adblocker. I use microsoft edge, are there other settings for autoplay I have to switch on other than the windows settings? Please help!!!


Report Comment



i have the exact same problem ugh

by ☆ Molly; ; Report

EmoFag666

EmoFag666's profile picture

Hey everyone!! This code didn't work for me either but I found a code that works! My friend shared it on his blog post. Here's the link to the post: https://blog.spacehey.com/entry?id=211407

Remember to ONLY copy the id of the video in

video id

.

For example, in https://youtu.be/3TPKjPJUEvo, only copy 3TPKjPJUEvo


Report Comment



the blog is private D:

by toonkidd; ; Report

TYSM IT WORKS PERFECTLY

by yk0uma; ; Report

My pleasure!! I'm so glad it worked for you:D

by EmoFag666; ; Report

Veroniikuh_♡

Veroniikuh_♡'s profile picture

hi what if i wanted to add a sound from soudcloud?


Report Comment

Семён Семененко

Семён Семененко's profile picture

Mine autoplays most of the time but the player is still visible. how do i make it completely invisible?


Report Comment



After writing this i wondered if its my layout thats the issue, will test it later

by Семён Семененко; ; Report

your style sets all iframes to 66% opacity

by Cory ; ; Report

Ah yea that would do it LOL, thanks

by Семён Семененко; ; Report

oliver

oliver's profile picture

tysm!!


Report Comment

Cuban Ricki

Cuban Ricki 's profile picture

Need help


Report Comment



how did you get yours to work?

by Vibe Smith; ; Report

VSOE✨

VSOE✨'s profile picture

how do i do it its not working need help :(


Report Comment



i need help too omg

by Plushhpinkk💞; ; Report

Oh Dats Brazil

Oh Dats Brazil 's profile picture

not working


Report Comment



same!

by Surfboart Sashaa; ; Report

Make sure your web browser allows audio to play automatically, however you need to do that.

by Cory ; ; Report

Nisha❣️

Nisha❣️'s profile picture

need help with it not working


Report Comment

Naomiii ♥

Naomiii ♥'s profile picture

not working for me :((


Report Comment

𝗟𝗶𝗹𝗶𝗮𝗻

𝗟𝗶𝗹𝗶𝗮𝗻's profile picture

it wont play and the youtube video is missing on my profile


Report Comment



same, its not working for me either.

by Dark Queen; ; Report

Mr.timer ( Lucifer )

Mr.timer ( Lucifer )'s profile picture

it dont work for me


Report Comment



What are you having issues with? Maybe I can help! I just got it working.

by mossfaerie; ; Report

Rebel_R0xxx

Rebel_R0xxx's profile picture

tried this, got my friend @mixxc to try it, didnt work :-( help plz?


Report Comment



did you make sure you put your songs in a public playlist? Also did you make sure your browser allows auto-play?

by Cory ; ; Report

we found out a new way to make it work ^^; but yea it was unlisted and i made sure autoplay was on

by Rebel_R0xxx; ; Report

Please share the new way

by Cory ; ; Report

i think it was just a tweaked version of your way now that im looking at it o.o weird how it didnt work before

by Rebel_R0xxx; ; Report

can you share the code that you got to work please? im trying to get the original to work but its not

by testing layouts dni; ; Report

hi how did you get this to work? i've been trying for hours now please

by Meli; ; Report

petalsoffofyou

petalsoffofyou's profile picture

This worked thank you x x


Report Comment



no problem!

by Cory ; ; Report