本文整理汇总了PHP中Video::getFilenameOnFilestore方法的典型用法代码示例。如果您正苦于以下问题:PHP Video::getFilenameOnFilestore方法的具体用法?PHP Video::getFilenameOnFilestore怎么用?PHP Video::getFilenameOnFilestore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Video
的用法示例。
在下文中一共展示了Video::getFilenameOnFilestore方法的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: explode
}
$video->title = $title;
$video->description = $desc;
$video->access_id = $access_id;
$video->container_guid = $container_guid;
$tags = explode(",", $tags);
$video->tags = $tags;
// Save the entity to push attributes to database
// and to get access to guid if adding a new video
$video->save();
// we have a video upload, so process it
if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
$prefix = "video/{$video->getGUID()}/";
// if previous video, delete it
if ($new_video == false) {
$videoname = $video->getFilenameOnFilestore();
if (file_exists($videoname)) {
unlink($videoname);
}
// use same videoname on the disk - ensures thumbnails are overwritten
$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