Skip to content

Instantly share code, notes, and snippets.

@mohamedmansour
Created July 6, 2012 09:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mohamedmansour/3059276 to your computer and use it in GitHub Desktop.
Save mohamedmansour/3059276 to your computer and use it in GitHub Desktop.
Google+ Hangouts On Air Embed
<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>
@shynes
Copy link

shynes commented Mar 17, 2013

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment