You are here

function brightcove_status in Brightcove Video Connect 7.3

Same name and namespace in other branches
  1. 6.2 brightcove.module \brightcove_status()
  2. 6 brightcove.module \brightcove_status()
  3. 7.2 brightcove.module \brightcove_status()
  4. 7.4 brightcove.module \brightcove_status()
  5. 7.5 brightcove.module \brightcove_status()

Return the status of a specific video.

Parameters

string $code: The code for the Brightcove video.

boolean $reset: (Optional) If TRUE, then reset the cached status.

Return value

string The status code returned by Brightcove.

File

./brightcove.module, line 618
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_status($code, $reset = FALSE) {
  static $status;
  if (!isset($status) || $reset) {
    $status = array();
  }
  if (!isset($status[$code])) {
    $cid = 'brightcove:status:' . $code;
    if ($cache = brightcove_cache_get($cid)) {
      $status[$code] = $cache->data;
    }
    else {
      $bc = brightcove_initialize();
      try {

        // Get the status of the desired status.
        $status[$code] = $bc
          ->getStatus('video', $code);
      } catch (BCMAPIException $error) {
        watchdog('brightcove', 'Unhandled error from Brightcove when retrieving the status of video ID %video: %error', array(
          '%video' => $code,
          '%error' => $error
            ->getMessage(),
        ), WATCHDOG_ERROR);
        $status[$code] = 'ERROR';
      }
      brightcove_cache_set($cid, $status[$code], 'cache');
    }
  }
  return $status[$code];
}