With this wrapper class you can fetch information from multiple video services in a uniformed and unique way. You only need the URL from the video service you are going to use.
To include this video in a post you only need to know the url of the video. Panorama-PHP API will handle all the background connections to supported video services for getting all the video information:
$video = new \Panorama\Video("http://www.youtube.com/watch?v=GPQnbtldFyo") $video->getTitle() => "paradon del portero" $video->getThumbnail() => "http://i4.ytimg.com/vi/GPQnbtldFyo/default.jpg" $video->getEmbedUrl() => "http://www.youtube.com/v/GPQnbtldFyo" $video->getEmbedHTML()(width, height) => "<object> [...]</object>" $video->getFLV() => "http://...flv" # or all together :) $video->getVideoDetails(width, height) => { 'title' => ..., 'thumbnail' => ..., 'embed_url' => ..., 'embed_html' => ..., 'flv' => ... }
This library depends on
Please don't ask for PHP < 5.3 support, you shouldn't use PHP 5.2 at all.
The idea is make it as simple as possible. For a URL video like http://vimeo.com/1785993:
$video = new \Panorama\Video("http://vimeo.com/1785993")
Then you have methods to know information about the video in your application.
getTitle: A method to know the title of the video of the service.
$video.getTitle() => "Beached"
getService: A method to know the name of the video provider service.
$video.getService()=> "Vimeo"
getThumbnail: An image representation of the video. Each service has a different size, but... it works :)
$video.getThumbnail()
=> "http://bc1.vimeo.com/vimeo/thumbs/143104745_640.jpg"
getEmbedUrl: The url (with flashvars) of the video player.
$video.getEmbedUrl()
=> "http://vimeo.com/moogaloop.swf?clip_id=1785993 [...] &show_portrait=1"
getEmbedHTML(width, height): Uses the embed_url to build an oembed string. The default width x height is 425 x 344, but we can specify a different one.
$video.getEmbedHTML(400, 300)
=> "<object width='400' height='300'><param name='mo [...] 300'></embed></object>"
getFLV: Gets the flv url. Not all the services has this option. Remember that in some services the flv url expires and in their terms don't allow using the flv without its player.
$video.getFLV
=> "http://www.vimeo.com/moogaloop/play/clip:1785993/ [...] 8ee400/video.flv"
getVideoDetails(width, height): All together :), returns all the previous elements in a hash. Width and height can be specified to build the embed_html.
$video.getVideoDetails() => "array( [...] )"
At this moment we support the following video services:
These services were included in this API but, due changes in their website, don't work anymore. Any patch for fixing them are welcome. ;)
If you detect new broken services by running the tests please let me know.
We are always open to incude new services.
Fran Diéguez (fran@openhost.es)
Fran Diéguez (fran@openhost.es)
You can download this project in either zip or tar formats.
You can also clone the project with Git by running:
$ git clone git://github.com/frandieguez/Panorama-PHP