本文整理汇总了PHP中Video::getFileDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Video::getFileDirectory方法的具体用法?PHP Video::getFileDirectory怎么用?PHP Video::getFileDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Video
的用法示例。
在下文中一共展示了Video::getFileDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: video_create_thumbnails
/**
* Make thumbnails of given video position. Defaults to beginning of video.
*
* @param Video $video The video object
* @param int $position Video position
*/
function video_create_thumbnails($video, $position = 0)
{
$icon_sizes = elgg_get_config('icon_sizes');
$square = elgg_get_plugin_setting('square_icons', 'video');
// Default to square thumbnail images
if (is_null($square)) {
$square = true;
}
$square = $square == 1 ? true : false;
$dir = $video->getFileDirectory();
$guid = $video->getGUID();
// Use default thumbnail as master
$imagepath = "{$dir}/icon-master.jpg";
try {
$thumbnailer = new VideoThumbnailer();
$thumbnailer->setInputFile($video->getFilenameOnFilestore());
$thumbnailer->setOutputFile($imagepath);
$thumbnailer->setPosition($position);
$thumbnailer->execute();
} catch (exception $e) {
$msg = elgg_echo('VideoException:ThumbnailCreationFailed', array($video->getFilenameOnFilestore(), $e->getMessage(), $thumbnailer->getCommand()));
error_log($msg);
elgg_add_admin_notice('video_thumbnailing_error', $msg);
return false;
}
$files = array();
// Create the thumbnails
foreach ($icon_sizes as $name => $size_info) {
// We have already created master image
if ($name == 'master') {
continue;
}
$resized = get_resized_image_from_existing_file($imagepath, $size_info['w'], $size_info['h'], $square);
if ($resized) {
$file = new ElggFile();
$file->owner_guid = $video->owner_guid;
$file->container_guid = $guid;
$file->setFilename("video/{$guid}/icon-{$name}.jpg");
$file->open('write');
$file->write($resized);
$file->close();
$files[] = $file;
} else {
error_log("ERROR: Failed to create thumbnail '{$name}' for video {$video->getFilenameOnFilestore()}.");
// Delete all images if one fails
foreach ($files as $file) {
$file->delete();
}
return false;
}
}
$video->icontime = time();
return true;
}
示例2: chmod
$videostorename = $video->getFilename();
$videostorename = elgg_substr($videostorename, elgg_strlen($prefix));
} else {
$videostorename = elgg_strtolower($_FILES['upload']['name']);
}
$video->setFilename($prefix . $videostorename);
$mime_type = ElggFile::detectMimeType($_FILES['upload']['tmp_name'], $_FILES['upload']['type']);
$video->setMimeType($mime_type);
$video->originalvideoname = $_FILES['upload']['name'];
$video->simpletype = 'video';
// Open the video to guarantee the directory exists
$video->open("write");
$video->close();
move_uploaded_file($_FILES['upload']['tmp_name'], $video->getFilenameOnFilestore());
// Change the directory mode
chmod($video->getFileDirectory(), 0775);
$guid = $video->save();
}
// video saved so clear sticky form
elgg_clear_sticky_form('video');
// handle results differently for new videos and video updates
if ($new_video) {
if ($guid) {
elgg_load_library('elgg:video');
// Find out file info and save it as metadata
$info = new VideoInfo($video);
$video->resolution = $info->getResolution();
$video->bitrate = $info->getBitrate();
$video->duration = $info->getDuration();
// Mark the video as unconverted so conversion script can find it
$video->conversion_done = false;