Beispiel #1
0
    $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
    $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) {
 public function parseVideo($videoObject)
 {
     $video = new Video();
     $video->setFileId($videoObject->file_id);
     $video->setWidth($videoObject->width);
     $video->setHeight($videoObject->height);
     $video->setDuration($videoObject->duration);
     if (property_exists($videoObject, 'thumb')) {
         $video->setThumb($this->parsePhotoSize($videoObject->thumb));
     }
     if (property_exists($videoObject, 'mime_type')) {
         $video->setMimeType($videoObject->mime_type);
     }
     if (property_exists($videoObject, 'file_size')) {
         $video->setFileSize($videoObject->file_size);
     }
     return $video;
 }