You are here

function brightcove_field_preprocess_brightcove_field_embed in Brightcove Video Connect 7.5

Same name and namespace in other branches
  1. 7.3 brightcove_field/theme.inc \brightcove_field_preprocess_brightcove_field_embed()
  2. 7.4 brightcove_field/theme.inc \brightcove_field_preprocess_brightcove_field_embed()

The brightcove_field_embed theme function preprocess function.

Parameters

$variables:

File

brightcove_field/theme.inc, line 70
Theme funciton for the module.

Code

function brightcove_field_preprocess_brightcove_field_embed(&$variables) {
  if (!isset($variables['player'])) {
    watchdog('brightcove', 'Brightcove player is missing.', array(), WATCHDOG_ERROR);
  }
  $player = brightcove_player_load($variables['player']);
  $variables['id'] = 'myExperience-' . $variables['id'];
  $variables['bgcolor'] = '#FFFFFF';
  $variables['width'] = isset($variables['width']) ? $variables['width'] : BRIGHTCOVE_DEFAULT_VIDEO_WIDTH;
  $variables['height'] = isset($variables['height']) ? $variables['height'] : BRIGHTCOVE_DEFAULT_VIDEO_HEIGHT;
  $variables['responsive'] = FALSE;
  $variables['smart_api'] = FALSE;

  // If player should be responsive.
  if (!is_null($player) && $player->responsive || variable_get('brightcove_player_responsive', FALSE)) {
    $variables['responsive'] = TRUE;
    drupal_add_css(drupal_get_path('module', 'brightcove_field') . '/styles/responsive.css');
  }

  // If we should use Smart player API.
  if (variable_get('brightcove_player_smart_api', FALSE)) {
    $variables['smart_api'] = TRUE;

    // Add width and height to client side to be able to use it by Smart Player API.
    drupal_add_js(array(
      'brightcoveField' => array(
        $variables['id'] => array(
          'width' => $variables['width'],
          'height' => $variables['height'],
        ),
      ),
    ), 'setting');
  }
  if (isset($variables['brightcove_id'])) {
    $variables['player_id'] = isset($player->player_id) ? $player->player_id : '';
    $variables['player_key'] = isset($player->player_key) ? $player->player_key : '';
    if (drupal_strtolower($variables['type']) == 'brightcove') {
      $variables['is_vid'] = TRUE;
    }
    elseif (drupal_strtolower($variables['type']) == 'brightcove-player') {
      $variables['is_vid'] = FALSE;
    }
  }
}