You are here

function brightcove_status in Brightcove Video Connect 7.2

Same name and namespace in other branches
  1. 6.2 brightcove.module \brightcove_status()
  2. 6 brightcove.module \brightcove_status()
  3. 7.3 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 301
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])) {
    if ($cache = cache_get('brightcove:status:' . $code, 'cache')) {
      $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';
      }
      cache_set('brightcove:status:' . $code, $status[$code], 'cache', CACHE_TEMPORARY);
    }
  }
  return $status[$code];
}