frandieguez/panorama-php

Wrapper class for accessing video services information in a standarized way

Installs: 432

Dependents: 0

Stars: 17

Watchers: 3

Forks: 6

Open Issues: 3

Language: PHP

1.0.10 2015-05-21 14:45 UTC

README

What is this!

With this wrapper class you can manage any video service in a uniformed and unique way. You only need the URL from the video service you are going to use.

A quick example:

To include this video in a post you only need to know the url of the video. With Panorama-PHP API you get this 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"
    # all together :)
    $video.getVideoDetails(width, height) => {
                                            'title' => ...,
                                            'thumbnail' => ...,
                                            'embed_url' => ...,
                                            'embed_html' => ...,
                                            'flv' => ...
                                          }

Install it!

  1. Just put in one of your include_path folders, and make sure to use an PSR-0-compatible autoloader.

Dependencies

This library only depends on PHP 5.4, you have to use namespaces and some other goodies of 5.4 version.

Please don't ask for PHP < 5.4 support, you shouldn't use PHP 5.3.

Use it!

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( [...] )"
    

Supported services

At this moment we support the following video services:

Broken 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.

Test it!

Help us to mantain this library updated. Run our behaviour tests with behat to give us feedback about what services don't work anymore.

For running tests:

  1. Install in your system Behat: http://docs.behat.org/quick_intro.html#method-1-pear
  2. Install Symfony 2 ClassLoader: http://pear.symfony.com/
  3. By using your terminal go to the features/ folder
  4. And simply run behat from there: behat

Build Status

68747470733a2f2f7365637572652e7472617669

And... what else?

If you find a bug or want to suggest a new video service, please let us know in a ticket.

Thanks!!