You are here

function brightcove_video_load in Brightcove Video Connect 6

Same name and namespace in other branches
  1. 6.2 brightcove.module \brightcove_video_load()
  2. 7.7 brightcove.video.inc \brightcove_video_load()
  3. 7.2 brightcove.module \brightcove_video_load()
  4. 7.3 brightcove.module \brightcove_video_load()
  5. 7.4 brightcove.module \brightcove_video_load()
  6. 7.5 brightcove.module \brightcove_video_load()
  7. 7.6 brightcove.video.inc \brightcove_video_load()

Loads Brightcove video from BC Media API. Uses a 5 minutes cache to speed up lookups.

Parameters

$video_id: Brightcove Studio video ID.

$cache: TRUE or FALSE. Whether to return a video from cache, if present.

Return value

$video Video object or FALSE if video not found.

15 calls to brightcove_video_load()
brightcove_cck_browser_validate in brightcove_cck/brightcove_cck.module
Validate callback for the field.
brightcove_cck_browser_value in brightcove_cck/brightcove_cck.module
Callback for Brightcove CCK browser widget. Will return a field value in "video-name [id:videoId]" format.
brightcove_cck_field in brightcove_cck/brightcove_cck.module
Implementation of hook_field().
brightcove_cck_handler_field_video::render in brightcove_cck/views/brightcove_cck_handler_field_video.inc
brightcove_cck_handler_field_video_date::render in brightcove_cck/views/brightcove_cck_handler_field_video_date.inc

... See full list

File

./brightcove.module, line 146
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function brightcove_video_load($video_id, $cache = TRUE) {
  $cache = cache_get('bc:video:' . $video_id, 'cache');
  $video = $cache->data;
  if (!empty($video->id)) {
    return $video;
  }
  else {
    $bc = _brightcove_initialize();
    try {
      $video = $bc
        ->find('find_video_by_id', $video_id);
    } catch (Exception $error) {
      watchdog('brightcove', 'Loading Brightcove video failed.', array(), WATCHDOG_ERROR);
      return FALSE;
    }
    if (!empty($video->id)) {
      cache_set('bc:video:' . $video_id, $video, 'cache', $_SERVER['REQUEST_TIME'] + 300);
      return $video;
    }
  }
  return FALSE;
}