You are here

public function BlazyOEmbed::getAutoPlayUrl in Blazy 8.2

Provides the autoplay url suitable for lightboxes, or custom video trigger.

Parameters

string $url: The embed URL, not input URL.

Return value

array The settings array containing autoplay URL.

Overrides BlazyOEmbedInterface::getAutoPlayUrl

1 call to BlazyOEmbed::getAutoPlayUrl()
BlazyOEmbed::preprocessMediaOembedIframe in src/BlazyOEmbed.php
Overrides variables for media-oembed-iframe.html.twig templates.

File

src/BlazyOEmbed.php, line 193

Class

BlazyOEmbed
Provides OEmbed integration.

Namespace

Drupal\blazy

Code

public function getAutoPlayUrl($url = '') {
  $data = [];
  if (!empty($url)) {
    $data['oembed_url'] = $url;

    // Adds autoplay for media URL on lightboxes, saving another click.
    if (strpos($url, 'autoplay') === FALSE || strpos($url, 'autoplay=0') !== FALSE) {
      $data['autoplay_url'] = strpos($url, '?') === FALSE ? $url . '?autoplay=1' : $url . '&autoplay=1';
    }
  }
  return $data;
}