0
votes

I'm trying to embed a YouTube video by using an iframe and their public API. I want the video to replay however, even while using their loop parameter my video ends after the first play.

API Docs for loop:

In the case of a single video player, a setting of 1 causes the player to play the initial video again and again. In the case of a playlist player (or custom player), the player plays the entire playlist and then starts again at the first video.

Supported values are 0 and 1, and the default value is 0.

Note: This parameter has limited support in the AS3 player and in IFrame embeds, which could load either the AS3 or HTML5 player. Currently, the loop parameter only works in the AS3 player when used in conjunction with the playlist parameter. 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: https://www.youtube.com/v/VIDEO_ID? version=3 &loop=1 &playlist=VIDEO_ID

(updated) Example video: https://codepen.io/denver-bohling/pen/jYegyq

1
All you have to do is actually do what it says there, and it works ... the video id is 0CUuvFjicqk, but for some reason you decided to append &playlist= kWN5HfEiN9A? at the end ... Do as is says, and voila: codepen.io/anon/pen/ppxBWRCBroe
Long story short -- that's there because I'm helping someone, and I changed their video to a short one for testing purposes. I didn't change the playlist param nor catch that they left a leading space before the value. If you want to put your comment in as an answer I'll accept it. Thanksrawkfist0215

1 Answers

1
votes

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

Problem with the code in the codepen was that the wrong playlist id was appended (plus whitespace before and a question mark after the value.)

With the correct video id specified as the playlist id as well, it loops fine:

<iframe src="https://www.youtube.com/embed/0CUuvFjicqk?autoplay=1&loop=1&playlist=0CUuvFjicqk"></iframe> 

(Embedding did not work as a code snippet here, iframe would not load, but here's the modified pen: https://codepen.io/anon/pen/ppxBWR)