Created
July 6, 2012 09:45
-
-
Save mohamedmansour/3059276 to your computer and use it in GitHub Desktop.
Google+ Hangouts On Air Embed
This file contains 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
<html> | |
<!-- | |
// Uses YouTube Live Feeds API: | |
// https://developers.google.com/youtube/2.0/developers_guide_protocol_retrieving_live_events | |
// | |
// Usage: | |
// 1) Copy paste the code below to your page. | |
// 2) Remember to replace your YouTube [USER_NAME] in the last script element to your own, for example, DariaMusk | |
// 3) You can add CSS Style to the first DIV element to make it look pretty and resize it to any size (normal CSS). | |
// | |
--> | |
<!-- START Copy --> | |
<div id="live-youtube-feed"><p>No live show, you can make this area cooler. Style this to add width/height/etc.</p></div> | |
<script type="text/javascript"> | |
function onActiveLiveFeeds(feeds) { | |
if (!data.feed.entry) return; | |
var lastFeedIdx = data.feed.entry.length - 1; | |
var lastLiveFeed = data.feed.entry[lastFeedIdx]; | |
var parts = lastLiveFeed.content.src.split('/'); | |
var liveVideoURL = parts[parts.length-1].split('?')[0]; | |
var iframe = document.createElement('iframe'); | |
iframe.src = 'http://www.youtube.com/embed/' + liveVideoURL; | |
iframe.width = '100%'; | |
iframe.height = '100%'; | |
iframe.setAttribute('frameborder', '0'); | |
iframe.setAttribute('allowfullscreen', 'true'); | |
var videoRoot = document.getElementById('live-youtube-feed'); | |
if (videoRoot) { | |
videoRoot.innerHTML = ''; | |
videoRoot.appendChild(iframe); | |
} | |
} | |
</script> | |
<script src="https://gdata.youtube.com/feeds/api/users/[USER_NAME]/live/events?v=2&status=active&alt=json-in-script&callback=onActiveLiveFeeds" type="text/javascript" defer="defer"></script> | |
<!-- END Copy --> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I gave this a try and it didnt' work. I changed the username to my channel, and did a hangout and nothing. :( does it work ?