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_mp3/main.php

37 lines
1 KiB
PHP
Raw Normal View History

2020-01-26 13:19:35 +00:00
<?php declare(strict_types=1);
class MP3FileHandler extends DataHandlerExtension
{
public function onMediaCheckProperties(MediaCheckPropertiesEvent $event)
{
switch ($event->ext) {
case "mp3":
2020-01-29 20:22:50 +00:00
$event->image->audio = true;
$event->image->video = false;
$event->image->lossless = false;
$event->image->image = false;
2020-02-23 16:05:09 +00:00
$event->image->width = 0;
$event->image->height = 0;
break;
}
// TODO: Buff out audio format support, length scanning
}
protected function create_thumb(string $hash, string $type): bool
{
copy("ext/handle_mp3/thumb.jpg", warehouse_path(Image::THUMBNAIL_DIR, $hash));
return true;
}
protected function supported_ext(string $ext): bool
{
$exts = ["mp3"];
return in_array(strtolower($ext), $exts);
}
protected function check_contents(string $tmpname): bool
{
2020-02-23 18:14:15 +00:00
return getMimeType($tmpname) == 'audio/mpeg';
}
}