Oembed-js is a Google Appengine application coded in Python. It relays YouTube oembed calls and offers results also in JSONP format, so javascript applications can use it.
Parameters
url: the (youtube) url to embed (best to be urlencoded)
maxwidth: max width of embedded object (optional)
maxheight: max height of embedded object (optional)
format: json/jsonp or xml (optional, default:json/jsonp)
callback or jsonp: the javascript callback function, required, if jsonp format is wanted
callID: a call ID that is passed through to response (optional)
Sample call:
http://oembed-js.appspot.com/?callback=foo&callID=123&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGMra5Wh51oU
Response
YouTube oEmbed response in json(p) or xml format, including field html (see oembed specs), and:
callID: if callID was given, it is passed through (can identify the response)
url: pass through the url that is being embedded
videoid: contains 11 char long YouTube videoid, if single video embed
playlist: contains playlist id, if playlist embed
Sample response:
foo({"provider_url": "http://www.youtube.com/", "version": "1.0", "title": "Sviatoslav Richter in Kiev, 1958 - Pictures at an Exhibition", "url": "http://www.youtube.com/watch?v=GMra5Wh51oU", "type": "video", "videoid": "GMra5Wh51oU", "thumbnail_width": 480, "height": 344, "width": 459, "html": "<iframe width=\"459\" height=\"344\" src=\"http://www.youtube.com/embed/GMra5Wh51oU?fs=1&feature=oembed\" frameborder=\"0\" allowfullscreen></iframe>", "author_name": "FirstPublicChannel", "callID": "123", "provider_name": "YouTube", "thumbnail_url": "http://i4.ytimg.com/vi/GMra5Wh51oU/hqdefault.jpg", "thumbnail_height": 360, "author_url": "http://www.youtube.com/user/FirstPublicChannel"})
Another demo how to use it
This demo and its source is also here in this jsFiddle.
Update March 27th 2012: Now oembed-js supports youtu.be urls (YouTube oembed service does not support them). Also now supports videos which have embedding turned off (YouTube oembed does not support these either).
Click on a single comment to hide/show its text
3 comments:
I've read before master.
Used jQuery plugin too, but with use it http://gdata.youtube.com/
I do not know about the script :D
ty master :)
@Beben Koben Do you have a email master? may i know ;)
@Beben Koben Hi, I sent you an email. :)
I've used YouTube gdata API, too. That offers video title, author, length, and other info. For example gdata url for video: http://gdata.youtube.com/feeds/api/videos/6TgUGM_qNq4
and for playlist: http://gdata.youtube.com/feeds/api/playlists/7F72BA632D96098B
Actually I was thinking if I would return also some gdata info, mainly video length, with the oEmbed data. But that would require another call to youtube services, and I'm not sure if I will do that.
See the hack to make the 'Post a Comment' link bigger.
Post a Comment