2007-12-06 11:53:43 +00:00
|
|
|
<?php
|
2009-08-20 23:37:17 +01:00
|
|
|
/*
|
2010-01-05 10:32:39 +00:00
|
|
|
* Name: Handle MP3
|
2007-12-06 11:53:43 +00:00
|
|
|
* Author: Shish <webmaster@shishnet.org>
|
|
|
|
* Description: Handle MP3 files
|
|
|
|
*/
|
|
|
|
|
2009-07-16 20:20:53 +01:00
|
|
|
class MP3FileHandler extends DataHandlerExtension {
|
|
|
|
protected function create_thumb($hash) {
|
|
|
|
$ha = substr($hash, 0, 2);
|
|
|
|
// FIXME: scale image, as not all boards use 192x192
|
|
|
|
copy("ext/handle_mp3/thumb.jpg", "thumbs/$ha/$hash");
|
2007-12-06 11:53:43 +00:00
|
|
|
}
|
|
|
|
|
2009-07-16 20:20:53 +01:00
|
|
|
protected function supported_ext($ext) {
|
2008-04-08 15:41:11 +00:00
|
|
|
$exts = array("mp3");
|
2009-06-05 12:53:00 -07:00
|
|
|
return in_array(strtolower($ext), $exts);
|
2008-04-08 15:41:11 +00:00
|
|
|
}
|
|
|
|
|
2009-07-16 20:20:53 +01:00
|
|
|
protected function create_image_from_data($filename, $metadata) {
|
2007-12-06 11:53:43 +00:00
|
|
|
global $config;
|
|
|
|
|
|
|
|
$image = new Image();
|
|
|
|
|
|
|
|
// FIXME: need more flash format specs :|
|
|
|
|
$image->width = 0;
|
|
|
|
$image->height = 0;
|
2009-01-04 11:18:37 -08:00
|
|
|
|
2007-12-06 11:53:43 +00:00
|
|
|
$image->filesize = $metadata['size'];
|
|
|
|
$image->hash = $metadata['hash'];
|
|
|
|
$image->filename = $metadata['filename'];
|
|
|
|
$image->ext = $metadata['extension'];
|
2009-01-24 11:05:07 -08:00
|
|
|
$image->tag_array = Tag::explode($metadata['tags']);
|
2007-12-06 11:53:43 +00:00
|
|
|
$image->source = $metadata['source'];
|
|
|
|
|
|
|
|
return $image;
|
|
|
|
}
|
|
|
|
|
2009-07-16 20:20:53 +01:00
|
|
|
protected function check_contents($file) {
|
2007-12-06 11:53:43 +00:00
|
|
|
// FIXME: mp3 magic header?
|
|
|
|
return (file_exists($file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_event_listener(new MP3FileHandler());
|
|
|
|
?>
|