gdd yt lecture wave2 1

99

Upload: alexander

Post on 30-May-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 1/99

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 2/99

Build YOUR YouTube

Nicola Ferioli

Customer Solutions Engineer 

October, 2008

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 3/99

3

• Video hosting is hard

• Building a repository of videos takes time

• YouTube.com provides free exposure

Why use the API?

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 4/99

4

• To create an online video community

• Upload from anything, syndicate anywhere

• We're not white label hosting

• Syndicated content is branded

Why did we create the API?

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 5/99

5

All the functionality of YouTube, available on your web site• Search YouTube

• Find relevant videos

• Manage favorites, playlists, subscriptions, etc.

• Upload videos

All the functionality to integrate into YOUR website

• Watch Videos• Chromeless player 

• Play/pause/stop…

Build YOUR YouTube

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 6/99

6

Interacting with YouTubeYouTube Data APIs

1. Read functions

2. Write functions

3. Upload functions

Integrating YouTube into your website

1. Embedded Player 

2. Chromeless Player 

3. Player controls

Agenda

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 7/99

YouTube Data API

1. Read Functions

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 8/99

8

• Simple standard protocol for reading andwriting data on the web

• Based on AtomPub

• RESTful API built on XML and HTTP

GData Protocol

Schema Namespace Prefix Schema URLAtom Syndication Format [None] - this is the default namespace http://www.w3.org/2005/Atom

Open Search Schema openSearch http://a9.com/-/spec/opensearchrss/1.0/

Yahoo! Media RSS Module media http://search.yahoo.com/mrss/

YouTube XML Schema yt http://www.youtube.com/schemas/yt/0.2

Google Data Schema gd http://schemas.google.com/g/2005

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 9/99

9

Friendster 

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 10/99

10

iPhone

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 11/99

11

Videossearch, related, responses, standardfeeds

User playlists, contacts, profiles, messages, subscriptions

Data API Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 12/99

12

Video Feeds

• Video feeds represent a set of videos – Search results

 – Standard feeds

 – Related videos

 – User favorites

 – User uploads

 – Playlist contents

 – Video responses

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 13/99

13

Video Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 14/99

14

Video Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 15/99

15

<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' …>

<id>http://gdata.youtube.com/…/standardfeeds/most_viewed</id> …

<link rel='next' type='application/atom+xml'

href=‘…viewed?start-index=26&max-results=25&time=all_time'/>

<openSearch:totalResults>100</openSearch:totalResults>

<openSearch:startIndex>1</openSearch:startIndex>

<openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry>

<id>http://…/feeds/api/videos/dMH0bHeiRNg</id> …

<title type='text'>Evolution of Dance</title> …

<author><name>judsonlaipply</name>…</author> …

<media:group> … </media:group> …

</entry>

<entry>

<id>http://…/feeds/api/videos/cQ25-glGRzI</id> …

<title type='text'>Avril Lavigne - Girlfriend</title>

</feed>

Video Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 16/99

16

<entry><id>http://…/feeds/api/videos/dMH0bHeiRNg</id> …

<category scheme=‘…/keywords.cat' term='Dancing'/> …

<category scheme=‘…/categories.cat' term='Comedy‘

label='Comedy'/>

<title type='text'>Evolution of Dance</title>

<content type='text'>The funniest 6 minutes…</content>

<link rel='alternate' type='text/html‘href='http://www.youtube.com/watch?v=dMH0bHeiRNg'/>

<link rel='http://…/schemas/2007#video.responses‘

type='application/atom+xml‘

href='http://…/videos/dMH0bHeiRNg/responses'/>

<link rel='http://…/schemas/2007#video.related‘

type='application/atom+xml‘

href='http://…/videos/dMH0bHeiRNg/related'/>

<media:group> …

Video Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 17/99

17

…<media:group> ...

<yt:duration seconds='360'/>

<media:content url='http://www.youtube.com/v/dMH0bHeiRNg‘

type='application/x-shockwave-flash' medium='video‘

isDefault='true‘ expression='full' duration='360‘

yt:format='5'/> …

<media:player url='http://youtube.com/watch?v=dMH0bHeiRNg'/><media:thumbnail

url='http://img.youtube.com/vi/dMH0bHeiRNg/2.jpg‘

height='97' width='130' time='00:03:00'/> …

</media:group>

<yt:statistics viewCount='84153989' favoriteCount='443906'/>

<gd:rating min='1' max='5' numRaters='312593' average='4.65'/>

<gd:comments>

<gd:feedLink href='http://…/videos/dMH0bHeiRNg/comments‘

countHint='151497'/>

</gd:comments>

</entry>

Video Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 18/99

18

Search

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 19/99

19

/feeds/api/videos?vq=<search>

Search

• Category/tag:

http://gdata.youtube.com/feeds/api/videos/-/News

http://gdata.youtube.com/feeds/api/videos/-/cute

http://gdata.youtube.com/feeds/api/videos?vq=chat&orderby=relevance_lang

_fr

http://gdata.youtube.com/feeds/api/videos?vq=chat&lr=fr

• Re-order: “relevance”, “published”, “viewCount”, “rating”

• Restrict language: lr 

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 20/99

20

• Flash embeddable (format 5)• Mobile formats over RTSP

 – H.263 with AMR audio (format 1)

 – MPEG-4 SP with AAC audio (format 6)

http://gdata.youtube.com/feeds/api/videos?vq=chat&format

=5

• Restrict format:

Search

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 21/99

21

Standard feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 22/99

22

/feeds/api/standardfeeds/<feed-name>

Standard feeds

• Feeds: featured, most viewed, top rated, …http://gdata.youtube.com/feeds/api/standardfeeds/most_vi

ewed

http://gdata.youtube.com/feeds/api/standardfeeds/IT/top_

rated

http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today

http://gdata.youtube.com/feeds/api/standardfeeds/top_rated_Sports

• Localised:

• Time window: today, this week, …

• Category:

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 23/99

23

Related Videos

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 24/99

24

/feeds/api/videos/<video-id>/related

Related Videos

• Returns a list of videos related to the video id

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 25/99

25

User Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 26/99

26

User Feeds

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 27/99

27

Playlists

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 28/99

28

/feeds/api/users/<username>/playlists

Playlists

• Each playlist has:

- Title

- Description- Tags

- <gd:feedLink> pointing to playlist contents

<entry><category scheme='http://.../tags.cat' term='snowboard'/>

<title type='text'>April 26 2008 at Squaw Valley</title><content type='text'>A few videos from snowboarding at SquawValley on April 26, 2008</content><gd:feedLink rel='http://…/schemas/2007#playlist' 

href='http://…/feeds/api/playlists/190CCAA9B6D4481B'countHint='4'/>

</entry>

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 29/99

29

/feeds/api/playlists/<playlist-id>

Playlist contents

• Almost identical to search results, standard feeds, etc.

• Playlist contents have <yt:position>

<entry><title type='text'>Android Demo</title> ...<yt:position>1</yt:position></entry><entry><title type='text'>A first hand look at building an Androidapplication</title> …<yt:position>2</yt:position></entry>

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 30/99

30

Subscriptions

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 31/99

31

/feeds/api/users/<username>/subscriptions

Subscriptions

• There are multiple types of subscriptions:

- Channel

- Favorites

- Search query

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 32/99

32

<entry>

<id>http://…/users/mortms/subscriptions/ac3a969d054c3f98</id>

<category scheme='http://…/schemas/2007/subscriptiontypes.cat‘

term='channel'/>

<yt:username>lonelygirl15</yt:username>

<gd:feedLink rel='http://…/schemas/2007#user.uploads‘

href='http://…/feeds/api/users/lonelygirl15/uploads‘

countHint='309'/>

</entry>

<entry>

<id>http://…/users/mortms/subscriptions/83bd95e382641fc2</id>

<category scheme='http://…/schemas/2007/subscriptiontypes.cat‘

term='query'/><yt:queryString>virginia tech</yt:queryString>

<gd:feedLink rel='http://…/schemas/2007#video.query‘

href='http://…/feeds/api/videos?vq=virginia+tech'/>

</entry>

Subscriptions

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 33/99

33

Favorites and User Uploads

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 34/99

34

/feeds/api/users/<username>/favorites

Favorites and User Uploads

• Simple collection of videos marked as “Favorite” by user 

/feeds/api/users/<username>/uploads

• Set of videos uploaded by the user 

- If not logged in – returns live, public videos only

- If logged in – returns all user’s uploads

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 35/99

35

• Projections allow you to get just the data you’reinterested in:

• All relevant data, using plain text instead of HTML

• Simple responses with HTML for display

• Most compact responses for low-bandwidth mobiledevices.

http://gdata.youtube.com/feeds/mobile/...

http://gdata.youtube.com/feeds/base/...

http://gdata.youtube.com/feeds/api/...

Projections

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 36/99

36

How fresh are the results?

• Search results can be outdated

• Latency has been greatlyimproved!

• New videos appears in minutes

• Statistics may take longer 

• Direct access to video gives fresh data

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 37/99

37

Errors

404 Not Found• When:

- resource does not exist- resource has been deleted

• What to do:- be ready- let the user know - with a nice message

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 38/99

38

Errors

503 Service Unavailable• When:

- “ Houston, we have a problem! ”- we're doing maintenance

• What to do:- retry once immediately- give up... but let your user knowh

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 39/99

39

Embedded Player Example

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 40/99

YouTube Data API

2. Write Functions

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 41/99

41

• Access to restricted information – Private videos

 – Private playlists

 – Inbox (video sharing)

 – Status of videos being processed

• Required for all write operations

 – Modify favorites, playlists, subscriptions

 – Rate, comment, respond to videos

 – Upload and manage videos

Why should users log in?

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 42/99

42

Two ways to sign in:• Web applications use AuthSub

 – Users log in on a Google web page

 – Browser gets redirected back to your site with

authentication token• Installed applications use ClientLogin

 – Users enter credentials in your application

 – Your application makes a login request

 – Your application gets issued a temporary authenticationtoken

Login

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 43/99

43

1. Redirect user to AuthSub authentication page

https://www.google.com/accounts/AuthSubRequest?

– next=http://www.example.com/yt_integration

– scope=http://gdata.youtube.com 

– session=1

– secure=0

AuthSub

https://www.google.com/accounts/AuthSubRequest?

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 44/99

44

AuthSub

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 45/99

45

AuthSub

2. Receive token

3. Exchange for session token

4. Add Authorization header to requests

http://www.example.com/yt_integration?token=<one-time-

token>

https://www.google.com/accounts/AuthSubSessionToken

Authorization: AuthSub token="my token"

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 46/99

46

Errors

401 Not Authorized• When:

- you need to log in- you need to log in AGAIN

• What to do:- ask your user to log in- expect it at any time

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 47/99

47

• Make POST requests to create a new entry: – Favorite

 – Playlist or playlist item

 – Subscription

 – Comments & Responses

 – Contacts

• Some feeds are write-only

 – Ratings

 – Complaints

Write - Basic operations

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 48/99

48

Developer Key

Write operations require a developer key and a clientID

Register your application to receive a developer key

Authorization: AuthSub token=“<token>”

X-GData-Key: key=<developer-key>

X-GData-Client: key=<client-id>

http://code.google.com/apis/youtube/dashboard

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 49/99

49

Write Example

Add a favorite video to a user's account

POST /feeds/api/users/default/favorites HTTP/1.1

Host: gdata.youtube.com

X-GData-Key: key=<developer-key>

X-GData-Client: key=<client-id>

Authorization: AuthSub token="<token>"Content-Type: application/atom+xml

<?xml version='1.0' encoding='UTF-8'?>

<entry xmlns='http://www.w3.org/2005/Atom'>

<id>[video_id]</id>

</entry>

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 50/99

YouTube Data API

3. Upload Functions

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 51/99

51

Animoto

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 52/99

52

Animoto

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 53/99

53

 YouTube-enabled devices

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 54/99

54

Two models for upload

• Direct Upload

 – For installed applications

 – For web apps, if you have (or want) a copy of the video

• Browser Upload

 – For web apps only

 – Your app controls the metadata

 – User uploads the video directly to YouTube

Upload

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 55/99

55

Direct Upload

POST /feeds/api/users/default/uploads HTTP/1.1

Host: uploads.gdata.youtube.comX-GData-Key: key=<developer-key>

X-GData-Client: key=<client-id>

Authorization: AuthSub token="<token>"

Content-Type: multipart/related; boundary=Arbitrary-

String

Slug: original_file.mp4

--Arbitrary-String

Content-Type: application/atom+xml

<entry>...</entry>

--Arbitrary-StringContent-Type: video/mp4

Content-Transfer-Encoding: binary

[Binary data of file]

--Arbitrary-String--

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 56/99

56

Browser Based Upload

• Process work-flow

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 57/99

57

Browser Based Upload

POST /actions/GetUploadToken HTTP/1.1X-GData-Key: key=<developer-key>

X-GData-Client: key=<client-id>

Authorization: AuthSub token=“<token>”

Content-Type: application/atom+xml; charset=UTF-8

<entry> …

<media:category

scheme=http://.../schemas/2007/developertags.cat>

  my_user_id=john</media:category>

</entry>

<?xml version='1.0' encoding='UTF-8'?><response>

 

<url>http://uploads.gdata.youtube.com/action/FormDataUpload/AIw

…<url>

<token>AIwbFAS…b9gtLCYjoE-</token>

</response>

• POST Metadata (including developer tags)

• Receive upload URL and token

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 58/99

58

<form

action="http://uploads.gdata.../FormDataUpload/AIw...?

nexturl=http://mysite.com/upload_complete“

method="post“ enctype="multipart/form-data">

Video File: <input type="file" name="file"/>

<input type="hidden" name="token" value="AIw…YjoE-"/>

<input type="submit"/>

</form>

http://mysite.com/upload_complete?status=200&id=GTdQIBGl

Emg

• Display upload form

• User gets redirected to your site on completion

Browser Based Upload

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 59/99

59

• Not public, so will not show up in public feeds

• Retrieve from authenticated user uploads feed:GET /feeds/api/users/default/uploads/GTdQIBGlEmg 

HTTP/1.1

X-GData-Key: key=<developer-key>

X-GData-Client: key=<client-id>

Authorization: AuthSub token=“<token>”

• Check for status tags (not present means video is live):

<app:control xmlns:app='http://purl.org/atom/app#'>

<app:draft>yes</app:draft>

<yt:state name='processing'/></app:control>

• Also check when showing all of user’s uploads

Checking Video Status

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 60/99

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 61/99

61

• Developer tags are simply a category scheme

• Search with standard category syntax

 – {category_scheme}category_name

GET /feeds/api/videos/-/

{…/schemas/2007/developertags.cat}my_user_id=john HTTP/1.1

X-GData-Key: key=<developer-key>

X-GData-Client: key=<client-id>

Searching with developer tags

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 62/99

62

Browser-Based Upload: Dogbook

C

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 63/99

63

Collecting Metadata

C ll ti M t d t

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 64/99

64

Collecting Metadata

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 65/99

G tti Vid Fil

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 66/99

66

Getting Video File

G tti Vid Fil

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 67/99

67

Getting Video File

G tti Vid ID

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 68/99

68

Getting Video ID

M ki Y T it

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 69/99

69

Marking Your Territory

M ki Y T it

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 70/99

70

Marking Your Territory

Errors

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 71/99

71

Errors

400 Bad Request

• When:- your request is wrong

• What to do:- check your request

- check the error message- parse the XML error 

<?xml version="1.0" encoding="UTF-8"?>

<errors>

<error>

<domain>yt:validation</domain>

<code>too_long</code>

<location type="xpath">media:group/media:keywords/text()</location>

</error>

<error>

<domain>yt:validation</domain>

<code>required</code>

<location type="xpath">media:group/media:title/text()</location>

</error>

</errors>

Client Libraries

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 72/99

72

Client Libraries

• Java

• PHP

• .NET (C#)

• Python

Client Library Snippet: PHP

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 73/99

73

Client Library Snippet: PHP

$yt = new Zend_Gdata_YouTube()

$videoFeed =

$yt->getVideoFeed(Zend_Gdata_YouTube::STANDARD_TOP_RATED_URI)

foreach ($videoFeed as $videoEntry) {

echo ‘Video title: ‘ . $videoEntry->getVideoTitle() .

“\n”;

Client Library Snippet: Python

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 74/99

74

Client Library Snippet: Python

yt = gdata.youtube.service.YouTubeService()

yt.developer_key = ‘devkeyhere’yt.client_id = ‘my-client-application-name’

yt.GenerateAuthSubURL(next, scope, secure, session)

yt.SetAuthSubToken(authsub_token)

yt.UpgradeToSession()

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 75/99

Integrating YouTube

4. Embedded Player 

Embedded Player Features

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 76/99

76

• Control basic look

• Create custom players based on playlists• Control with JavaScript or AS2

Embedded Player Features

Embedded Player Example

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 77/99

77

Embedded Player Example

<object width="425" height="344">

<param name="movie" value="http://www.youtube.com/v/ADos_xW4_J0"></param>

<embed src="http://www.youtube.com/v/ADos_xW4_J0"

type="application/x-shockwave-flash" width="425" height="344">

</embed>

</object>

Player Parameters

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 78/99

78

Player Parameters

Hide related menu

http://www.youtube.com/v/VIDEO_ID?color1=0x2b405b&color2=0x6b8ab6&border

=1

http://www.youtube.com/v/VIDEO_ID?start=60

http://www.youtube.com/v/VIDEO_ID?rel=0

Add border/colors

Start where the action starts

http://www.youtube.com/v/VIDEO_ID?loop=1&autoplay=1

Annoy your users

Embedded and Custom Players

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 79/99

79

Embedded and Custom Players

Custom Players can be made on http://youtube.com/custom_player 

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 80/99

Integrating YouTube

5. Chromeless Player 

Chromeless Player

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 81/99

81

Chromeless Player 

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 82/99

Chromeless Player

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 83/99

83

Chromeless Player 

Chromeless Player

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 84/99

84

Chromeless Player 

For ActionScript just load the player SWF

http://www.youtube.com/apiplayer

For JavaScript use SWFObject

swfobject.embedSWF("http://www.youtube.com/apiplayer

?

enablejsapi=1",...)

• open source project, new standard for embedding AdobeFlash Player content

• checks Flash Player version, can offer alternative contentor download option

• takes care of browser compatibility issues

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 85/99

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 86/99

Integrating YouTube

6. Player Controls

Player Controls

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 87/99

87

Player Controls

• JavaScript & ActionScript2

• Issue commands to player 

• Listen for events

• Poll status of player 

Sample Functions

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 88/99

88

Sample Functions

•playVideo / pauseVideo / stopVideo

•seekTo

•getCurrentTime / getDuration

•getVideoBytesLoaded /getVideoBytesTotal

•Mute / unMute / isMuted

•setVolume / getVolume

Player APIs Example

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 89/99

89

Player APIs Example

http://code.google.com/apis/youtube/chromeless_example_1.html

Synchronised Video and Slides

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 90/99

90

Synchronised Video and Slides

http://mg.to/

Synchronised Video and Map

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 91/99

91

Synchronised Video and Map

http://blog.deconcept.com/ytmapmashup/

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 92/99

Video Search on your site

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 93/99

93

y

http://www.google.com/uds/solutions/wizards/videosearch.html http://www.nextego.com

Galaxy

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 94/99

94

y

http://galaxy.tkaap.com/

Want to try it?

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 95/99

95

y

http://code.google.com/p/yt-codelab/

But also!...

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 96/99

96

http://www.youtube.com/watch?v=kvBiSW5QFKY

• Annotations

 – Cat

http://www.youtube.com/watch?v=dO-Bq01XtHM

 – Guitar 

http://www.youtube.com/watch?v=XraeBDMm2PM

• Subtitles

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 97/99

97

Questions?

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 98/99

98

Learn more

http://code.google.com

8/14/2019 GDD YT Lecture Wave2 1

http://slidepdf.com/reader/full/gdd-yt-lecture-wave2-1 99/99