This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/handle_video/theme.php

52 lines
1.6 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
2023-12-30 13:01:36 +00:00
use function MicroHTML\{A, BR, VIDEO, SOURCE, emptyHTML};
class VideoFileHandlerTheme extends Themelet
{
public function display_image(Image $image): void
{
global $config, $page;
2023-11-11 21:49:12 +00:00
$width = "auto";
if ($image->width > 1) {
$width = $image->width."px";
}
2023-11-11 21:49:12 +00:00
$height = "auto";
if ($image->height > 1) {
$height = $image->height."px";
}
2023-12-30 13:01:36 +00:00
$html = emptyHTML(
"Video not playing? ",
A(['href' => $image->get_image_link()], "Click here"),
" to download the file.",
BR(),
VIDEO(
[
'controls' => true,
'class' => 'shm-main-image',
'id' => 'main_image',
'alt' => 'main image',
'poster' => make_http($image->get_thumb_link()),
'autoplay' => $config->get_bool(VideoFileHandlerConfig::PLAYBACK_AUTOPLAY),
'loop' => $config->get_bool(VideoFileHandlerConfig::PLAYBACK_LOOP),
'muted' => $config->get_bool(VideoFileHandlerConfig::PLAYBACK_MUTE),
'style' => "height: $height; width: $width; max-width: 100%; object-fit: contain; background-color: black;",
'onloadstart' => 'this.volume = 0.25',
],
SOURCE([
'src' => $image->get_image_link(),
'type' => strtolower($image->get_mime())
])
)
);
$page->add_block(new Block("Video", $html, "main", 10));
}
}