HTML Auto Embedding Recent Uploaded Videos from a Youtube Channel

HTML Auto Embedding Recent Uploaded videos from a youtube channel

<!DOCTYPE html>
<html>
<head>
<title>YouTube Recent Upload Thing</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
</head>
<body>
<div id="static_video"></div>
<script type="text/javascript">
function showVideo(response) {
if(response.data && response.data.items) {
var items = response.data.items;
if(items.length>0) {
var item = items[0];
var videoid = "http://www.youtube.com/embed/"+item.id;
console.log("Latest ID: '"+videoid+"'");
var video = "<iframe width='420' height='315' src='"+videoid+"' frameborder='0' allowfullscreen></iframe>";
$('#static_video').html(video);
}
}
}
</script>
<script type="text/javascript" src="https://gdata.youtube.com/feeds/api/users/urusernamehere/uploads?max-results=1&orderby=published&v=2&alt=jsonc&callback=showVideo"></script>
</body>
</html>

How can I automatically embed the latest youtube video?

Create a playlist for your channel and use the "advanced" playlist settings to make a rule that automatically adds videos. You could add all videos with a specific tag.

Then, sort the playlist by the newest publication date if you want the "latest" upload.

The URL for your embed tag will look like this:

https://www.youtube.com/embed/?list={PLAYLIST_ID}

Embedding most recent YouTube video with Channel ID

It is stated in the Player Parameter of Iframe API that the list parameter, in conjunction with the listType parameter, identifies the content that will load in the player.

  • If the listType parameter value is user_uploads, then the list parameter value identifies the YouTube channel whose uploaded videos
    will be loaded.

It is not stated here that you need to place Channel ID in the list parameter. The list parameter value identifies the YouTube channel whose uploaded videos will be loaded.

So what you need to place here is the USER NAME.

example

https://www.youtube.com/user/Nightblue3

Try to use the Nightblue3 here in the list parameter of your request. And your embed video will work.

For more information, check this related SO question.

Auto-embed YouTube videos [Before last]

Answer found !

With js and not only html :
There's the code



Related Topics



Leave a reply



Submit