jennatar's profile picture

Layout published by jennatar

published
updated

Add to Favorites

View Layouts

View Profile

Report Layout

How to Hide, Loop, and Autoplay the Embedded YouTube Player

Tags: youtube, music, embed, iframe, loop, autoplay, looping, hide, hidden, player

Description:

One of the most enjoyably evil traditions of y2k-era web design was hiding a music player somewhere on your website or profile page and setting it to autoplay.

I realize I'm standing on the shoulders of giants (and I'll update the description with links to the other code snippets and comments/commenters I've borrowed info from), but the missing piece--how to actually force a song to loop--was hidden right here, on the Google developers' API documentation for the YouTube player:

This parameter (loop) has limited support in IFrame embeds. To loop a single video, set the loop parameter value to 1 and set the playlist parameter value to the same video ID already specified in the Player API URL.

In other words, YouTube's embedded iframe player interprets your looping music as a playlist, but a playlist that only has one song on it. As such, you need to get the video's ID by checking the actual url (youtube.com/watch?v=VIDEO_ID) and then replace the VIDEO_ID text both times it appears in the layout code.

The code snippet below also sets the player to 0 pixels wide and 0 pixels tall but, in some browsers (as another user discovered), you need to use the css tag class="hideobj" to hide the iframe player instead. If you want to kindly allow visitors to pause the audio, just remove the aforementioned tag entirely, and change the iframe player's dimensions to those of your choosing. :)

To make your song play only once (rather than indefinitely), you'll want to also change the text in the code from loop=1 to loop=0. Good luck!

Editing to add: Make sure this code snippet for YouTube's iframe player does not appear inside your css's "style" tags. I have mine just after the last </style>, before any actual text.

Copy and paste this code into the "About me" section of your Profile to use it.

Caution: This Layout was not inspected by SpaceHey — use it at your own risk.


Comments

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

nova ๐Ÿ’—

nova ๐Ÿ’—'s profile picture

using!


Report Comment

JeaN

JeaN's profile picture

usinggg!!!


Report Comment

teegs

teegs's profile picture

OMGG IT WORKSS!!


Report Comment

Puppet

Puppet's profile picture

FINALLY IT WORKED, THANK YOU!!! โ—(แต”แ—œแต”)โ—œ


Report Comment

kaiserstar

kaiserstar's profile picture

Using!!


Report Comment

Angel6ix66

Angel6ix66's profile picture

YESSS THANK YOU SMMM USINGG !!!!!!!!!!


Report Comment

figgleberry.yoinkscale

figgleberry.yoinkscale's profile picture

This is awesome!! thanks you so much!


Report Comment

SundSora

SundSora's profile picture

using!! tysm :3


Report Comment

Bas3M3ntRaT!

Bas3M3ntRaT!'s profile picture

USINGGGG
TY SO MUCHHH!!!


Report Comment

knxxca

knxxca's profile picture

using! thank you so much! <3


Report Comment

Connie <3

Connie <3's profile picture

Finally got it to work!!! Unfortunately the song I've picked starts VERY loud so it scares me everytime I close my profile but alas. (/j) ty for this!!! /gen!!


Report Comment

cyberspace2004

cyberspace2004's profile picture

looping doesnt work.


Report Comment

Oreo

Oreo's profile picture

Using! :3


Report Comment

Ray!

Ray!'s profile picture

Using! Tysm I've spent hours trying to figure it out, every other tutorial or code doesn't work but this one is a miracle!! :D


Report Comment

rocc+

rocc+'s profile picture

using!


Report Comment

LiU XwX

LiU XwX's profile picture

using !! :3


Report Comment

Gabriel Leon

Gabriel Leon's profile picture

using!


Report Comment

s!mp_030

s!mp_030's profile picture

using! tysm (/^_^)/


Report Comment

kels

kels's profile picture

using!!!!


Report Comment

Mizupie

Mizupie's profile picture

using!!! thxx


Report Comment