openvk/Web/Models/VideoDrivers/YouTubeVideoDriver.php

33 lines
954 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
2020-06-07 19:04:43 +03:00
namespace openvk\Web\Models\VideoDrivers;
final class YouTubeVideoDriver extends VideoDriver
{
public function getThumbnailURL(): string
2020-06-07 19:04:43 +03:00
{
return "https://img.youtube.com/vi/$this->id/mqdefault.jpg";
2020-06-07 19:04:43 +03:00
}
public function getURL(): string
2020-06-07 19:04:43 +03:00
{
return "https://youtu.be/$this->id";
}
public function getEmbed(string $w = "600", string $h = "340"): string
2020-06-07 19:04:43 +03:00
{
return <<<CODE
<iframe
width="$w"
height="$h"
src="https://www.youtube-nocookie.com/embed/$this->id"
frameborder="0"
sandbox="allow-same-origin allow-scripts allow-popups"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
CODE;
2020-06-07 19:04:43 +03:00
}
}