You are here

public function GoogleDrive::renderEmbedCode in Video Embed Google Drive 8

File

src/Plugin/video_embed_field/Provider/GoogleDrive.php, line 28

Class

GoogleDrive
A Google Drive provider plugin for video embed field.

Namespace

Drupal\video_embed_google_drive\Plugin\video_embed_field\Provider

Code

public function renderEmbedCode($width, $height, $autoplay) {
  $iframe = [
    '#type' => 'video_embed_iframe',
    '#provider' => 'google_drive',
    '#url' => sprintf('https://drive.google.com/file/d/%s/preview', $this
      ->getVideoId()),
    '#query' => [],
    '#attributes' => [
      'width' => $width,
      'height' => $height,
      'frameborder' => '0',
      'allowfullscreen' => 'allowfullscreen',
    ],
  ];

  // TODO: is this supported by google drive?
  // if ($time_index = $this->getTimeIndex()) {
  //   $iframe['#fragment'] = sprintf('t=%s', $time_index);
  // }
  return $iframe;
}