You are here

function brightcove_status in Brightcove Video Connect 6.2

Same name and namespace in other branches
  1. 6 brightcove.module \brightcove_status()
  2. 7.2 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()

File

./brightcove.module, line 264
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];
}