React Native vs Ionic - The Best Mobile App Framework
YouTube APIs presentation at Facultad de Ciencias, Universidad Nacional Autónoma de México
1. Building Video Apps
with YouTube APIs
UNAM Mexico City
Jarek Wilkiewicz
twitter.com/wjarek
04/01/2011
2. Agenda
• Intro
• Life of a video
• APIs
• Back-end (Google Data API)
• Front-end (Player)
• App Examples
• Q&A
3. Quiz *
Number of YouTube views per day ?
> your answer here
Number of mobile YouTube views per day?
> your answer here
How much video is uploaded each minute?
> your answer here
%-tage of views coming from outside of US?
> your answer here
*As of Oct 2010
4. Life of a video
• Uploading
• Sharing
• Searching
• Playback
Video : Evolution of Dance by Judson Laipply
http://www.youtube.com/watch?v=dMH0bHeiRNg
5. Life of a video : Uploading
• Via YouTube.com uploader
• Standard (POST)
• Advanced (Java)
• Mobile (mailto:xyz93a@m.youtube.com)
• Using the API
• Browser-based
• Direct
• Direct resumable (great for mobile)
• Metadata (category, keyword, etc.)
6. Life of a video : Sharing
• Autoshare
• Embed
• Publish to activity feed
7. Life of a video : Searching
http://gdata.youtube.com/feeds/api/videos?q=Google+Mexico&
orderby=published&
start-index=1&
max-results=10&v=2
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
[…]
<entry gd:etag='W/"C0AMRn47eCp7ImA9WxRQGUw."'>
<id>tag:youtube,2008:video:ZTUVgYoeN_b</id>
<published>2008-07-05T19:56:35.000-07:00</published>
<updated>2008-07-18T07:21:59.000-07:00</updated>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://gdata.youtube.com/schemas/2007#video'/>
[…]
</entry>
[...]
</feed>
8. Life of a video : Playback
On YouTube.com
On other sites
Custom Player
Embedded Player
Chromeless Player
On your mobile
On other devices
12. Google Data APIs
Protocol
REST-based
ATOM syndication format (RFC 4287)
ATOM publishing protocol (RFC 5023)
support for XML-based ATOM (default), JSON, JSON-C,
RSS
Feeds
Standard feeds (Top Rated, Most Viewed, ...)
User's playlists, subscriptions, uploads feeds
User's comments, profile, contacts feed
YouTube applications interact with the feeds using the
Google Data APIs
14. Feed access example in Java
import com.google.gdata.client.youtube.YouTubeService;
import com.google.gdata.data.youtube.VideoEntry;
import com.google.gdata.data.youtube.VideoFeed;
YouTubeService service = new YouTubeService(clientID,
developer_key);
VideoFeed videoFeed = service.getFeed(new URL(feedUrl),
VideoFeed.class);
printVideoFeed(videoFeed, true);
public static void printVideoFeed(VideoFeed videoFeed, boolean detailed) {
for(VideoEntry videoEntry : videoFeed.getEntries() ) {
printVideoEntry(videoEntry, detailed);
}
}
15. Other useful things one can do with the APIs
Upload
Search
Rate a video (Like/Dislike)
Comment
Add a playlist
Retrieve activity feed (SUP or PubSubHubbub)
Retrieve Insight video statistics
Get a better grade on your exam!
And more!
If your application obtains OAuth/AuthSub authorization from a
user, all of these can be done on user's behalf.
16. Performing video search in Python
import gdata.youtube.service
def PrintVideoFeed(feed):
for entry in feed.entry:
PrintEntryDetails(entry)
yt_service = gdata.youtube.service.YouTubeService()
yt_service.ssl = False
query = gdata.youtube.service.YouTubeVideoQuery()
query.vq = search_terms
query.orderby = 'viewCount'
feed = yt_service.YouTubeQuery(query)
PrintVideoFeed(feed)
17. Direct upload in C#
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.YouTube;
using Google.GData.Extensions.MediaRss;
YouTubeService service = new YouTubeService("exampleCo-exampleApp-1", clientID, developerKey);
service.setUserCredentials(username, password);
YouTubeEntry newEntry = new YouTubeEntry();
newEntry.Media = new MediaGroup();
newEntry.Media.Title = new MediaTitle("My Test Movie");
newEntry.Media.Categories.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newEntry.Media.Keywords = new MediaKeywords("cars, funny");
newEntry.Media.Description = new MediaDescription("My description");
newEntry.Private = false;
newEntry.Location = new GeoRssWhere(37, -122);
newEntry.MediaSource = new MediaFileSource("c:file.mov", "video/quicktime");
YouTubeEntry createdEntry = service.Upload(newEntry);
18. Player APIs
Control the Player from your Web front-end
URI parameters
JavaScript API
ActionScript API (Flash)
23. Mobile : Uploading
ACTION_SEND intent
Use Google Data protocol to
upload
Libraries available for leading
mobile platforms; you can use
direct REST/HTTP on others
34. YouTube Direct : Mobile
Easy authentication with
AccountMananger
Submission idea sync (JSON)
Notification upon new
assignments
Video recording and upload to a
specific submission idea
Upload of a video selected from
the gallery
Geolocation tagging
Massage and psychic readings
35.
36. One last thing ...
Read the Terms of
Service
Monetization Guide
Branding Guide
[1]
[1] Photo by sub_lime79 / Misty
http://www.flickr.com/photos/mistybushell/2303555607/
37. ToS
[1]
YouTube API Terms of Service
http://code.google.com/apis/youtube/terms.html
Monetization Guide
http://code.google.com/apis/youtube/creating_monetizable_applications.html
Branding Guide
http://code.google.com/apis/youtube/branding.html
[1] Photo by sub_lime79 / Misty
http://www.flickr.com/photos/mistybushell/2303555607/
38. Resources
Get the YouTube API developer key and start hacking!
http://code.google.com/apis/youtube/dashboard/gwt
http://code.google.com/apis/youtube (docs)
http://apiblog.youtube.com (blog)
http://code.google.com/apis/youtube/forum (forum)
twitter.com/wjarek (me)