You are here

public function Brightcove::renderEmbedCode in Video Embed Brightcove 8

File

src/Plugin/video_embed_field/Provider/Brightcove.php, line 65

Class

Brightcove
A Brightcove provider plugin.

Namespace

Drupal\video_embed_brightcove\Plugin\video_embed_field\Provider

Code

public function renderEmbedCode($width, $height, $autoplay) {

  // Get configured autoplay player name if needed.
  if ($autoplay) {
    $config = $this->configFactory
      ->get('video_embed_brightcove.settings');
    $player_name = $config
      ->get('autoplay_player');
  }

  // Use player name from the input URL if autoplay player is not set.
  if (empty($player_name)) {
    $player_name = $this
      ->getPlayerName();
  }
  return [
    '#type' => 'html_tag',
    '#tag' => 'iframe',
    '#attributes' => [
      'width' => $width,
      'height' => $height,
      'frameborder' => '0',
      'allowfullscreen' => 'allowfullscreen',
      'src' => sprintf('https://players.brightcove.net/%d/%s_default/index.html?videoId=%d', $this
        ->getPlayerId(), $player_name, $this
        ->getVideoId(), $autoplay),
    ],
  ];
}