You are here

function brightcove_admin_player_view in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.6 brightcove.player.inc \brightcove_admin_player_view()

Page callback for 'admin/config/media/brightcove/players/%/%/view'.

Parameters

string $bcid:

string $player_id:

Return value

array

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

File

./brightcove.player.inc, line 53

Code

function brightcove_admin_player_view($bcid, $player_id) {
  $client = brightcove_client_load($bcid);
  if (!$client) {
    drupal_not_found();
  }

  /** @var \Brightcove\API\PM $pm */
  list(, , $pm) = brightcove_create_classes($client);
  $build = brightcove_try(function () use ($bcid, $player_id, $pm) {
    $build = [];
    $player = $pm
      ->getPlayer($player_id);
    $preview_url = $player
      ->getBranches()
      ->getPreview()
      ->getPreviewUrl();
    $width = $player
      ->getBranches()
      ->getPreview()
      ->getConfiguration()
      ->getStudioConfiguration()
      ->getPlayer()
      ->getWidth();
    $height = $player
      ->getBranches()
      ->getPreview()
      ->getConfiguration()
      ->getStudioConfiguration()
      ->getPlayer()
      ->getHeight();
    $build['widget'] = [
      '#theme' => 'brightcove_player_preview',
      '#preview_url' => $preview_url,
    ];
    if ($width) {
      $build['widget']['#width'] = $width;
    }
    if ($height) {
      $build['widget']['#height'] = $height;
    }
    $build['embeds'] = [
      '#title' => t('Embeds'),
      '#theme' => 'item_list',
      '#items' => array_map(function (\Brightcove\Object\Player\Embed $embed) use ($bcid, $player_id) {
        return l($embed
          ->getName(), "admin/config/media/brightcove/players/{$bcid}/{$player_id}/{$embed->getId()}");
      }, $pm
        ->listEmbeds($player_id)
        ->getItems()),
    ];
    return $build;
  });
  if (!$build) {
    drupal_not_found();
  }
  return $build;
}