Created
April 12, 2012 14:18
-
-
Save planetoftheweb/2367632 to your computer and use it in GitHub Desktop.
Insert YouTube Channel Feed & Player into any site using JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
#videogroup { | |
width: 100%; | |
} | |
iframe { | |
width: 90%; | |
padding: 5%; | |
} | |
#myplayer .first iframe { | |
width: 100%; | |
padding: 0; | |
} | |
#videolist ul { | |
margin: 0; | |
padding: 0; | |
list-style: none; | |
} | |
#videolist li { | |
width: 50%; | |
float: left; | |
border: none; | |
position: relative; | |
} | |
#videolist li .entriestitle { | |
padding: 0 5px; | |
position: absolute; | |
left:80%; | |
top:20%; | |
display: none; | |
} | |
#videolist li:hover .entriestitle { | |
display: block; | |
width: 100%; | |
background: rgb(119, 25, 51); | |
border-radius: 10px; | |
color: #FFF; | |
padding: 10px; | |
opacity: .9; | |
z-index: 100; | |
right: 0; | |
} | |
</style> | |
<script type="text/javascript"> | |
function listVideos(data) { | |
var firstOutput=""; | |
var entries = data.feed.entry; | |
var myOutput = '<ul>'; | |
for (var i=0; i<data.feed.entry.length; i++) { | |
var entriesID=entries[i].id.$t.substring(38); | |
var entriesTitle=entries[i].title.$t; | |
var entriesDescription=entries[i].media$group.media$description.$t; | |
var entriesThumbnail=entries[i].media$group.media$thumbnail[0].url; | |
myOutput += '<li><div class="entriestitle">' + entriesTitle + '</div>'; | |
myOutput+='<iframe src="http://www.youtube.com/embed/'+entriesID+'?wmode=transparent&HD=0&rel=0&showinfo=0&controls=1&fs=1&autoplay="0" frameborder="0" allowfullscreen></iframe>'; | |
if (i==0) { | |
firstOutput += '<div class="first">'; | |
firstOutput += '<h2>' + entriesTitle + '</h2>'; | |
firstOutput += '<iframe src="http://www.youtube.com/embed/'+entriesID+'?wmode=transparent&HD=0&rel=0&showinfo=0&controls=1&autoplay="0" frameborder="0" allowfullscreen></iframe>'; | |
firstOutput += '<p>' + entriesDescription + '</p>'; | |
firstOutput += '</div>'; | |
document.getElementById('myplayer').innerHTML=firstOutput; | |
} | |
} | |
document.getElementById('videolist').innerHTML = myOutput; | |
myOutput +='</ul>'; | |
} | |
</script> | |
<div id="videogroup"> | |
<div id="myplayer"></div> | |
<div id="videolist"></div> | |
</div> | |
<script type="text/javascript" src="http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=listVideos&max-results=6&category=Villalobos"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your answer is surprisingly similar to an advertisement
Oh... wait... it's an advertisement!!