Skip to content Skip to sidebar Skip to footer

How To Get Youtube Playlist Video Id With Video Title

I need how to retrieved YouTube playlist video id and Video title using API key, if only we need last five updated videos in a YouTube playlist. How to got it please give me a pe

Solution 1:

I copied your code and added jQuery. Console shows you have already archieved your goal?

enter image description here

<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script>var channelName = 'mipaltan';
var vidHeight = 350;
var vidWidth = 650;
var vidMaxResult =7; // Maximum can be 50

$(document).ready(function () {
$.get("https://www.googleapis.com/youtube/v3/channels", {
part: 'contentDetails',
forUsername: channelName,
key: 'AIzaSyCT8kXaxJ2l29vYg4HBdYy36H-PhAH-Teg'//Browser API Key
},
function (data) {
$.each(data.items, function (i, item) {
console.log(item); // See in Browser Console
pid = item.contentDetails.relatedPlaylists.uploads;
getVideos(pid);
})
}
);
functiongetVideos(pid) {
$.get("https://www.googleapis.com/youtube/v3/playlistItems",
{
part: 'snippet',
maxResults: vidMaxResult,
playlistId: pid,
key: 'AIzaSyCT8kXaxJ2l29vYg4HBdYy36H-PhAH-Teg'//Browser API Key
},
function (data) {
var outputVideo;
$.each(data.items, function (i, item) {
console.log(item); // See in Browser Console
vidId = item.snippet.resourceId.videoId;
thumbnails = item.snippet.thumbnails.default.url;
texturl = 'https://www.youtube.com/embed/' + vidId;
mainurl = "'" + texturl + "'";
outputVideo = '<div style="float:left"><img style="width: 93px;height:65px; border-radius: 5px;margin-right:1px;" src="' + thumbnails + '"onclick="newSrc(' + mainurl + ')" /></div>';

$('#result').append(outputVideo);
})
}

);
}
});

</script><script>functionnewSrc(testurl) {
document.getElementById("MyFrame").src = testurl;
}
</script></head><body><divid="container"><iframeid="MyFrame"; width="670"; height="350"; src="https://www.youtube.com/embed/Yx9M-6cx8wA"frameborder="0"allowfullscreen></iframe><divstyle="padding-left:5px", id="result"class ="footer-widget"></div></div></body>

Post a Comment for "How To Get Youtube Playlist Video Id With Video Title"