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

36 lines
917 B
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
2020-06-14 16:05:55 +00:00
// TODO: Add support for generating an icon from embedded cover art
// TODO: MORE AUDIO FORMATS
class MP3FileHandler extends DataHandlerExtension
{
protected array $SUPPORTED_MIME = [MimeType::MP3];
2020-02-23 18:37:22 +00:00
protected function media_check_properties(MediaCheckPropertiesEvent $event): void
{
2020-02-23 18:37:22 +00:00
$event->image->audio = true;
$event->image->video = false;
$event->image->lossless = false;
$event->image->image = false;
$event->image->width = 0;
$event->image->height = 0;
// TODO: ->length = ???
}
protected function create_thumb(Image $image): bool
{
copy("ext/handle_mp3/thumb.jpg", $image->get_thumb_filename());
return true;
}
protected function check_contents(string $tmpname): bool
{
2020-06-14 16:05:55 +00:00
return MimeType::get_for_file($tmpname) === MimeType::MP3;
}
}