You are here

Dailymotion.php in Video 8.2

Same filename and directory in other branches
  1. 8 src/Plugin/video/Provider/Dailymotion.php

File

src/Plugin/video/Provider/Dailymotion.php
View source
<?php

namespace Drupal\video\Plugin\video\Provider;

use Drupal\video\ProviderPluginBase;

/**
 * @VideoEmbeddableProvider(
 *   id = "dailymotion",
 *   label = @Translation("Dailymotion"),
 *   description = @Translation("Dailymotion Video Provider"),
 *   regular_expressions = {
 *     "@dailymotion\.com/video/(?<id>[^/_]+)_@i",
 *   },
 *   mimetype = "video/dailymotion",
 *   stream_wrapper = "dailymotion"
 * )
 */
class Dailymotion extends ProviderPluginBase {

  /**
   * {@inheritdoc}
   */
  public function renderEmbedCode($settings) {
    $file = $this
      ->getVideoFile();
    $data = $this
      ->getVideoMetadata();
    return [
      '#type' => 'html_tag',
      '#tag' => 'iframe',
      '#attributes' => [
        'width' => $settings['width'],
        'height' => $settings['height'],
        'frameborder' => '0',
        'allowfullscreen' => 'allowfullscreen',
        'src' => sprintf('//www.dailymotion.com/embed/video/%s?autoPlay=$d', $data['id'], $settings['autoplay']),
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getRemoteThumbnailUrl() {
    $data = $this
      ->getVideoMetadata();
    return 'http://www.dailymotion.com/thumbnail/video/' . $data['id'];
  }

}

Classes

Namesort descending Description
Dailymotion Plugin annotation @VideoEmbeddableProvider( id = "dailymotion", label = @Translation("Dailymotion"), description = @Translation("Dailymotion Video Provider"), regular_expressions = { "@dailymotion\.com/video/(?<id>[^/_]+)_@i", }, …