Reputation: 31
Is it possible to create my own YouTube playlist with YouTube API?
I would like to take a list of YouTube id's, and append the videos to my page.
Is it possible?
Thank you
Upvotes: 1
Views: 4606
Reputation: 4161
HTML:
<div id="player"></div>
Javascript:
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady(event) {
//here you load your playlist
event.target.loadPlaylist(playlist: [youtubeIds]);
}
Upvotes: 0