Engineering and Developers Blog
What's happening with engineering and developers at YouTube
YouTube API Outgrows Shy Adolescence, Now Social
Tuesday, February 24, 2009
Posted by Stephanie Liu, YouTube APIs and Tools Team
YouTube has been
getting more social
lately, using activity feeds to make it easier to find cool videos and channels that your YouTube friends are favoriting, rating, subscribing to, etc. But what if all your friends aren't on YouTube, but rather on social network / site XYZ?
Well, my friends, the API has come out of its awkward teenage years, and now has more sophisticated social skills to help. Activities like favoriting, uploading, commenting, and more can now be integrated into the social context of your choice. Check out the
for the new user activity feed and friend activity feed.
Before you ask, the user activity feed is
by the user, and the corresponding feed through the API respects all privacy settings. So users still have full control over what they make available in their recent activity feed.
We think some cool apps can be made with these feeds -- like the obvious social network / feed aggregator integrations, to notification apps, to novel data views. We can't wait to see what you guys make!
Get started by perusing the docs and playing with the sample. Besides the
, we've also updated the
guides with helpful snippets. An
activity viewer sample
written in PHP and its
is also available for you to play with.
As always, let us know if you have any questions or feedback in the
PS. If you want to socialize with the team in person, come to
, where we'll be giving a
on "Going social with the YouTube APIs"!
TubeLoc: An AS3 Player Wrapper Using LocalConnection
Wednesday, February 11, 2009
Posted by Jeff Fisher, YouTube APIs and Tools Team
We know developers really like AS3, but sometimes they have difficulty getting our players to work correctly. To make this process easier for the Flashy/Flexy crowd, the awesome Ben Longoria has given us
TubeLoc is an AS3 wrapper around the Player API that uses LocalConnection to communicate to the AS2 YouTube SWFs. It takes this a step further by also providing Flex components to make inserting a YouTube video and controls easy.
Ready to get started? First
read the article
that goes in depth on how to use TubeLoc. Next, visit the
to download the code and play with the live demos. Finally, tell us what you think
on the forum
. Thanks Ben!
YouTube APIs + iPhone = Cool mobile apps
Thursday, February 5, 2009
Update (Nov. 2013)
: The information in this blog post is out of date; the current best practice for embedding YouTube videos in an iOS application is to use the
YouTube iframe Player
Posted by Kuan Yong, YouTube APIs and Tools Team
The YouTube APIs
Terms of Service
permits commercial use of the APIs
under certain conditions
, and in most cases, as long as you play fair, you are free (and highly encouraged) to develop great iPhone apps using the YouTube APIs and sell them in the iTunes App Store.
An iPhone app that uses the YouTube APIs typically needs to do two things:
Call the YouTube API Data API to search videos, get video metadata, etc. You should use our
Objective C client library
instead of trying to construct the HTTP request or parse the response by hand.
Invoke the native YouTube player on the iPhone to play videos.
There are at least two ways to play YouTube videos in your iPhone app (that don't run afoul of Apple's SDK rules). The easier way requires just one line of code but it involves quitting your app and launching the full YouTube app on the phone. The better way needs a little more setup but provides a seamless way of taking the user to the YouTube player and back to your app.
Note that these two methods work only on an actual device, not in the iPhone simulator, since the latter does not have a YouTube player.
Method 1: Open the YouTube play page URL (Easier)
1. Grab the video url from the
media tag in the API response with the
type. It should look something like this:
If you don't see the
parameters in the URL, it's because you are not passing in your developer key and client ID in the request. While they are not mandatory for read requests, we highly recommend that you provide them in
2. Open the URL in your app by calling the openURL method on your UIApplication instance:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"
When your app calls openURL, it will quit and launch the full native YouTube app on the phone. After the video stops playing, the user remains in the YouTube app. The user has no easy way of getting back to your app.
Method 2: Embed the YouTube player in a UIWebView
No, the iPhone still doesn't do Flash, but if you haven't already noticed, the Safari browser on the iPhone is clever enough to turn any YouTube embed into a clickable thumbnail that launches the native YouTube player app on the phone. You can take advantage of this feature in your app by using a UIWebView. Here's how:
1. Set up a UIWebView in your app. You can make it part of a xib or create it programmatically. Size the UIWebView according to how large you want the clickable thumbnail to be.
2. Grab the video url using the same method as the one described above.
3. Call the
method on the UIWebView instance with some carefully constructed HTML that contains the YouTube embedded player code snippet and some supporting HTML to make sure that the video thumbnail appears correctly. Set the base URL to the URL of your website (it doesn't do anything here -- ordinarily UIWebView uses it to handle relative URL links correctly).
The best way to illustrate this is with a code snippet. Note the use of the
HTML meta parameter and the consistent use of
// webView is a UIWebView, either initialized programmatically or loaded as part of a xib.
NSString *htmlString = @"<html><head>
<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>
<div><object width=\"212\" height=\"172\">
<param name=\"movie\" value=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"></param>
<param name=\"wmode\" value=\"transparent\"></param>
type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"212\" height=\"172\"></embed>
[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.your-url.com"]];
One of the biggest benefits of this approach is that your app does not have to quit in order for the video to start playing. In fact, the iPhone will keep your app running in the background while it fires up the YouTube player to play the video. After the video finishes playing (or when the user hits "Done"), the user is automatically taken back to your app. This experience is very similar to watching embedded YouTube videos in the iPhone Safari browser and is just as seamless.
Have fun writing the next killer iPhone app, and don't forget to list your app in the
YouTube Project Gallery
once it goes live in the App Store!
Coming up: Adding YouTube content to Android apps
Show Me the Money
Wednesday, February 4, 2009
Posted by Kuan Yong, YouTube APIs Product Manager
Money: it's on
everyone's mind lately
, and we know developers are no different. We understand that developers aren't just satisfied with creating the coolest YouTube mashup out there. They also want a way to sustain their efforts financially, and the trick is figuring out how to do so appropriately. That's why we've published a
that provides clear guidance on how you can monetize the apps you've built with the YouTube APIs. While it is not a substitute for reading our
Terms of Service
, it should point you to the clauses you should pay attention to and hopefully even give you some ideas for your next YouTube API-powered project.
So go ahead, launch the next great YouTube mashup, and monetize the hell out of it. And don't forget to tell us about your app at the
YouTube Project Gallery
google developers live
Live Streaming API
media:keywords keywords tags metadata
ssl https certificate staging stage
Super Chat API
YouTube Data API
youtube developers live
YouTube Reporting API
Press & Blog
Creators & Partners
YouTube Creator Blog
YouTube Trends Blog