youtube get all video paly list api code example
Example 1: javascript stream youtube muisic in background
<script src="http://www.youtube.com/player_api"></script>
<div id="player" style="position: absolute; top: -9999px; left: -9999px;"></div>
<div id="info">loading...</div>
<script src="http://www.youtube.com/player_api"></script>
<script>
var info = document.getElementById('info');
function onYouTubePlayerAPIReady() {
var player = new YT.Player('player', {
videoId: 'gzeOWnnSNjg',
loop: true,
events: {
onReady: function (e) {
info.innerHTML = 'video is loaded';
e.target.playVideo();
},
onStateChange: function (event) {
if (event.data === 1) {
info.innerHTML = 'video started playing';
}
}
}
});
}
</script>
Example 2: How do I get a YouTube video thumbnail from the YouTube API?
$data = file_get_contents("https://www.googleapis.com/youtube/v3/videos?key=YOUR_API_KEY&part=snippet&id=T0Jqdjbed40");
$json = json_decode($data);
var_dump($json->items[0]->snippet->thumbnails);