You are here

function brightcove_load_video in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.6 brightcove.module \brightcove_load_video()

Loads Brightcove video from CMS API.

Uses a 5 minutes cache to speed up lookups.

Parameters

string $video_id:

Entity $client_entity:

bool $reset:

Return value

\Brightcove\Object\Video\Video|bool Video object or FALSE on failure.

7 calls to brightcove_load_video()
BrightcoveVideoEntityController::create in ./brightcove.video.inc
Implements EntityAPIControllerInterface.
BrightcoveVideoEntityController::load in ./brightcove.video.inc
Overridden.
brightcove_field_browser_video_validate in ./brightcove.module
Validate callback for the video field.
brightcove_field_formatter_view in ./brightcove.module
Implements hook_field_formatter_view().
brightcove_field_validate in ./brightcove.module
Implements hook_field_validate().

... See full list

File

./brightcove.module, line 2297
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_load_video($video_id, Entity $client_entity, $reset = FALSE) {
  if (!$client_entity) {
    return FALSE;
  }
  brightcove_load_lib();
  $cid = "brightcove:video:{$video_id}:{$client_entity->bcid}";
  $cache = brightcove_cache_get($cid);
  if (!empty($cache) && !$reset) {
    return $cache;
  }
  else {
    $video = NULL;
    brightcove_try(function () use ($client_entity, $video_id, &$video) {

      /** @var \Brightcove\API\CMS $cms */
      list($cms, ) = brightcove_create_classes($client_entity);
      $video = $cms
        ->getVideo($video_id);
    });
    if ($video) {
      brightcove_cache_set($cid, $video);
      return $video;
    }
  }
  return FALSE;
}