You are here

class MediaVimeoStreamWrapper in Media: Vimeo 7

Same name and namespace in other branches
  1. 7.2 includes/MediaVimeoStreamWrapper.inc \MediaVimeoStreamWrapper

Create an instance like this: $vimeo = new ResourceVimeoStreamWrapper('vimeo://v/[video-code]');

Hierarchy

Expanded class hierarchy of MediaVimeoStreamWrapper

1 string reference to 'MediaVimeoStreamWrapper'
media_vimeo_stream_wrappers in ./media_vimeo.module
Implements hook_stream_wrappers().

File

includes/MediaVimeoStreamWrapper.inc, line 12
Create a Vimeo Stream Wrapper class for the Media/Resource module.

View source
class MediaVimeoStreamWrapper extends MediaReadOnlyStreamWrapper {
  static function getMimeType($uri, $mapping = NULL) {
    return 'video/vimeo';
  }

  /**
   * Call the Vimeo Simple API and fetch the video information.
   *
   * See http://vimeo.com/api/docs/simple-api
   *
   * @return
   *   Array of properties.
   */
  static function getVideoProperties($video_id) {

    // The .php format returns a serialized array.
    $response = drupal_http_request('http://vimeo.com/api/v2/video/' . $video_id . '.php');
    return unserialize($response->data);
  }
  function getTarget($f) {
    return FALSE;
  }
  function interpolateUrl() {
    return 'http://vimeo.com/' . intval($this->parameters['v']);
  }
  function getOriginalThumbnailPath() {
    $video_properties = self::getVideoProperties($this->parameters['v']);
    return $video_properties[0]['thumbnail_large'];
  }
  function getLocalThumbnailPath() {
    $local_path = 'public://media-vimeo/' . intval($this->parameters['v']) . '.jpg';
    if (!file_exists($local_path)) {
      $dirname = drupal_dirname($local_path);
      file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
      @copy($this
        ->getOriginalThumbnailPath(), $local_path);
    }
    return $local_path;
  }

}

Members