You are here

function brightcove_field_player in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.2 brightcove_field/brightcove_field.module \brightcove_field_player()
  2. 7.3 brightcove_field/brightcove_field.module \brightcove_field_player()
  3. 7.4 brightcove_field/brightcove_field.module \brightcove_field_player()
  4. 7.5 brightcove_field/brightcove_field.module \brightcove_field_player()
  5. 7.6 brightcove.module \brightcove_field_player()

Callback for brightcove_field_player - checks access to the field and prints a player for Lightbox2.

Parameters

$type: Type of the field.

$entity_type: Type of the entity.

$entity_id: Id of the entity.

$field_name: Field that is being displayed.

$delta: Field delta.

Return value

string

1 string reference to 'brightcove_field_player'
brightcove_menu in ./brightcove.module
Implements hook_menu().

File

./brightcove.module, line 1259
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_field_player($type, $entity_type, $entity_id, $field_name, $delta) {
  module_load_include('inc', 'brightcove', 'theme');
  $entities = entity_load($entity_type, [
    $entity_id,
  ]);
  $entity = array_shift($entities);

  // Get settings for the proper field instance.
  $field_info = field_info_instance($entity_type, $field_name, $entity->type);
  $width = !empty($field_info['display']['default']['settings']['width']) ? $field_info['display']['default']['settings']['width'] : BRIGHTCOVE_DEFAULT_VIDEO_WIDTH;
  $height = !empty($field_info['display']['default']['settings']['height']) ? $field_info['display']['default']['settings']['height'] : BRIGHTCOVE_DEFAULT_VIDEO_HEIGHT;
  $path = brightcove_get_experiences_js_url();
  drupal_add_js($path, [
    'type' => 'external',
    'defer' => FALSE,
    'async' => TRUE,
  ]);
  $field = field_get_items($entity_type, $entity, $field_name);
  $brightcove_id = $field[$delta]['brightcove_id'];
  $player = $field[$delta]['player'];
  $client = brightcove_client_load($field[$delta]['bcid']);
  if (!$player) {
    $instance = field_info_instance($entity_type, $field_name, $entity->type);
    $player = $instance['settings']['brightcove_player'] ? $instance['settings']['brightcove_player'] : variable_get('brightcove_player_default', '');
  }
  $variables = [
    'type' => $type === 'playlist' ? BRIGHTCOVE_EMBED_TYPE_PLAYLIST : BRIGHTCOVE_EMBED_TYPE_VIDEO,
    'brightcove_id' => $brightcove_id,
    'player_id' => $player,
    'account_id' => $client->account_id,
    'height' => $height,
    'width' => $width,
  ];
  return theme('brightcove_field_embed', $variables);
}