To play a single video, and play it again when it finishes, the loop parameter alone is not enough.
According to the YouTube IFrame API documentation on the player parameters , this is specified on the parameter loop :
Note: The compatibility of this parameter is limited in the AS3 player and the IFrame builds, which could load the AS3 player or the HTML5 player. Currently, the loop parameter only works with the AS3 player when used next to the parameter playlist . To loop a single video, set the loop parameter value to 1 and set the value of the in the same video ID that is specified in the player's API URL :
http://www.youtube.com/v/VIDEO_ID?version=3&loop=1&playlist=VIDEO_ID
So, in addition to the parameters that you already have in the player, you must add the playlist
parameter.
In this parameter a comma-separated list of IDs is specified as a value of the videos you want to play. In your case, you only want a single video to be played, then in that case you only need to specify the video ID:
playlist=VIDEO_ID
The value of the attribute src
of the element iframe
, without shredding, would look like this:
https://www.youtube.com/embed/JA6RTwGdTVY?playlist=JA6RTwGdTVY&controls=0&autoplay=1&loop=1&showinfo=0&rel=0
Shredded, it looks like this:
https://www.youtube.com/embed/JA6RTwGdTVY?
playlist=JA6RTwGdTVY /* Nuevo parámetro */
controls=0&
autoplay=1&
loop=1&
showinfo=0&
rel=0
Code
<div class="video-background">
<div class="video-foreground">
<iframe src="https://www.youtube.com/embed/JA6RTwGdTVY?playlist=JA6RTwGdTVY&controls=0&autoplay=1&loop=1&showinfo=0&rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
You can see it in action on this JSFiddle .
See also