You are here

function brightcove_field_player in Brightcove Video Connect 7.5

Same name and namespace in other branches
  1. 7.7 brightcove.module \brightcove_field_player()
  2. 7.2 brightcove_field/brightcove_field.module \brightcove_field_player()
  3. 7.3 brightcove_field/brightcove_field.module \brightcove_field_player()
  4. 7.4 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

$node: Node object.

$field_name: Field that is being displayed.

$delta: Field delta.

Return value

array

1 string reference to 'brightcove_field_player'
brightcove_field_menu in brightcove_field/brightcove_field.module
Implementation of hook_menu().

File

brightcove_field/brightcove_field.module, line 335
Brightcove field module provides a Content Construction Kit module to developers, allowing them to browse videos in their Brightcove Studio and upload them.

Code

function brightcove_field_player($type, $entity_type, $entity_id, $field_name, $delta) {
  module_load_include('inc', 'brightcove_field', 'theme');
  $entities = entity_load($entity_type, array(
    $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, array(
    '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'];
  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 = array(
    'type' => $type == 'playlist' ? 'brightcove-playlist' : 'brightcove',
    'brightcove_id' => $brightcove_id,
    'params' => array(
      'id' => 'brightcove-dialog-player',
    ),
    'player' => $player,
    'height' => $height,
    'width' => $width,
  );
  return theme('brightcove_field_embed', $variables);
}