Version 1
[yaffs-website] / web / modules / contrib / video / src / Plugin / video / Provider / Dailymotion.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\video\Plugin\video\Provider\Dailymotion.
6  */
7
8 namespace Drupal\video\Plugin\video\Provider;
9
10 use Drupal\video\ProviderPluginBase;
11
12 /**
13  * @VideoEmbeddableProvider(
14  *   id = "dailymotion",
15  *   label = @Translation("Dailymotion"),
16  *   description = @Translation("Dailymotion Video Provider"),
17  *   regular_expressions = {
18  *     "@dailymotion\.com/video/(?<id>[^/_]+)_@i",
19  *   },
20  *   mimetype = "video/dailymotion",
21  *   stream_wrapper = "dailymotion"
22  * )
23  */
24 class Dailymotion extends ProviderPluginBase {
25   /**
26    * {@inheritdoc}
27    */
28   public function renderEmbedCode($settings) {
29     $file = $this->getVideoFile();
30     $data = $this->getVideoMetadata();
31     return [
32       '#type' => 'html_tag',
33       '#tag' => 'iframe',
34       '#attributes' => [
35         'width' => $settings['width'],
36         'height' => $settings['height'],
37         'frameborder' => '0',
38         'allowfullscreen' => 'allowfullscreen',
39         'src' => sprintf('//www.dailymotion.com/embed/video/%s?autoPlay=$d', $data['id'], $settings['autoplay']),
40       ],
41     ];
42   }
43   
44   /**
45    * {@inheritdoc}
46    */
47   public function getRemoteThumbnailUrl() {
48     $data = $this->getVideoMetadata();
49     return 'http://www.dailymotion.com/thumbnail/video/' . $data['id'];
50   }
51 }