how to loop two videos using youtube iframe code - youtube

I use the following code in my web page to successfully autoplay and loop one video. Now, I'd like to add another video, essentially looping two videos. So, after one video is finished playing, the second video will start to play, and then the first video, and so on, and so froth. How should the code be modified to do that?
<iframe width="560" height="315" src=
"https://www.youtube.com/embed/51xS4yXbryc?
rel=0&version=3&playlist=51xS4yXbryc&loop=1
&autoplay=1" frameborder="0" allowfullscreen=""></iframe>
That is a one-line code. I break it into four lines so it's easier to read.

For add more than one video in your iframe, you can use the following code:
https://www.youtube.com/embed/<VIDEO_ID_1>?rel=0&version=3&playlist=<VIDEO_ID_2>,<VIDEO_ID_3>,<VIDEO_ID_N>&loop=1&autoplay=1
Where:
VIDEO_ID_1: is the first videoId to reproduce.
VIDEO_ID_2, VIDEO_ID_3, VIDEO_ID_N and so on will be the videoIds you want include.
In this way, you can include a max of 196 or 200 videos in the same iframe1 that will autoplay and loop once the final videoId is reached.
This is a small sample with 4 videos on it.
This is another sample with 93 videos on it.
If you check this playlist, you'll see that it has more than 1000 videos on it - (1653 videos to be exact), but, the iframe resets the threshold to 196 or 200 videos approximately.
1 I discover this threshold when I tried to answer this question in Stack Overflow and you can check it by yourself if you enter to the Youtube website - this playlist and check that it will show only the first 200 videos on it.
This might be a threshold set (and undocumented) by YouTube.

A similar question was asked before about iframe and looping. I found this from another question on stackoverflow, a youtube link has a special ? parameter: autoplay. For example in this link
src="https://www.youtube.com/embed/M7lc1UVf-VE ?&autoplay=1& loop=1&rel=0&showinfo=0&color=white&iv_load_policy=3&playlist=M7lc1UVf-VE"
Try adding ?&autoplay=1& considering that worked for someone else.
I found it from
here
Update
If you wanna play multiple videos you can do it simply and embed a
playlist. You can find how to do so in this article at the
Embed a playlist section. Hope this helps.

Related

Is it possible to upload YouTube shorts via the API?

I was looking through the Google API docs and could not find anything on uploading YouTube shorts. Does anybody know of a way?
As of today, it seems that "Shorts" are just plain Youtube videos, because really any Youtube video can be regarded as a "Shorts" video by appending its id to the shorts route, even if it's a 24 hours long video, for example this one: https://www.youtube.com/shorts/4dhIvyskkB0.
So just upload a video.
However, it seems that the question should better be: What could raise the chances that a Youtube video be "promoted" by Youtube as a "Shorts" video?
To which the answer is: Follow Youtube's guidelines, provided here:
Entitle your video with the #shorts hashtag (snippet.title).
Add the #shorts hashtag to your description (snippet.description).
Make it shorter than 60 seconds.
The videos endpoint request body documentation is here.
Maybe once "Shorts" get out of beta, things would get more strict.
I want to give a few updates, based on OfirD's answer, I can't edit the answer directly because there are too many pending edits.
you don't necessarily need to add the #shorts hashtag to (snippet.title & snippet.description).
You just need to upload a video with a 9:16 aspect ratio
Video with less than 60 seconds duration.
Refer to Upload YouTube Shorts to learn more details about Shorts.
Hope this helps!

Videojs with Youtube not displaying playlist

I am trying to use VideoJS to display a Youtube playlist (not a coded playlist. a Youtube playlist). My implementation is a copy of the example on the videojs-youtube github page: youtube-playlist
The video plays, but there is no playlist. Can anyone direct me?
I can post code. But, I am using the example.
https://github.com/videojs/videojs-youtube/blob/master/examples/youtube-playlist.html
I couldn't find an answer to my issue. But, I found a workaround. Posting here hoping it helps someone else.
Instead of pulling the playlist into videoJS, I wrote a script to pull in the playlist via Google's API, and wrote the output to html on the page.
See https://developers.google.com/youtube/v3/docs/playlistItems/list for info

Youtube API v3 only finds the first 100 pages of a Playlist

I am currently working on a project, which tries to get all videoIds from the Upload-Playlist of the channel "PietSmiet" (a German Let's Player with around 15,500 videos).
Finding the Id of the channel ("UCqwGaUvq_l0RKszeHhZ5leA") and the Id of the Upload-Playlist ("UUqwGaUvq_l0RKszeHhZ5leA") is easy and getting the first fifty videos of this list is possible too.
I know that one can see more pages/videos by setting/changing the pageToken,
but on the 100th page (pageToken="CNYmEAA") there is no nextPageToken, despite the fact, that there are 15414 videos overall in the playlist and that this page only shows the videos 4950-4999.
By changing the pageToken to "CIcnEAA" (this page starts at the 4999th video), I could get to the 5048th video, but there is still no nextPageToken.
Is this a bug or a limitation and is there a solution?

Youtube embedded player - show no recommendations (videos) at the end?

I have an am bedded youtube video in my site, but at the end of it, Youtube displays a set of recommendations (other videos) which I'd like to remove since they have nothing to do with my video.
Is that possible? Can't seem to find anything gin the Youtube embedded API :(
Just add ?rel=0 at the end of your video, &rel=0 no longer works
Example:
<iframe src="https://www.youtube.com/embed/hy9Cbp_yV5Y?rel=0"
width="100%" height="100%" frameborder="0"></iframe>
The trick is to attach to the player URL (http://www.youtube.com/v/Yc_J_kXaFSw) the rel=0 parameter.
The player URL will became http://www.youtube.com/v/Yc_J_kXaFSw&rel=0
The source of this information:
http://www.varesano.net/blog/fabio/disable%20related%20videos%20embedded%20youtube%20player
Just add &rel=0 at the end of your video url, this should remove the recommendations.

Youtube player for multiple videos from various accounts

I have a page that has many videos on it and the page has become so slow it is unusable. These are all Youtube videos and I changed to the new iFrame tags hoping that would help the loading. I need a solution to make this page more useable.
I would be happy if I could just pull a frame from the video and display that, when clicked it would load the video. Or I would be happy with a multi-video player. The custom play from Youtube will not work because the videos I am serving are not all from my account and as I understand the custom player you reference a group from your account. I have also considered using AJAX to load the iframe, which would be okay too if I could figure out how to get a thumbnail of the video to show as a link.
Ideas and suggestions are welcome. Thanks in advance for any ideas.
YouTube API is made up of 2 different sets - one for the player and one for the data.
You can start here ...
http://code.google.com/apis/youtube/overview.html
... then click on "Data API" link and after looking over that page, click on the "Reference Guide" link.
In essence, the gData API will allow you to get videos in numerous ways (feeds, channels, tops, etc) in chunks of up to 100 videos at a time, using a startIndex (or whatever it may be called) option for paging. What you get is an XML document with parts or everything that YT has about a video, including not one but several different thumbnail images.
HTH helps you and/or another Web 0.2 Fellow (like me)

Resources