Beispiel #1
0
 /**
  * @param string $config
  * @return Asset_Video_Thumbnail|null
  */
 public function getThumbnailConfig($config)
 {
     $thumbnail = null;
     if (is_string($config)) {
         try {
             $thumbnail = Asset_Video_Thumbnail_Config::getByName($config);
         } catch (Exception $e) {
             Logger::error("requested video-thumbnail " . $config . " is not defined");
             return null;
         }
     } else {
         if ($config instanceof Asset_Video_Thumbnail_Config) {
             $thumbnail = $config;
         }
     }
     return $thumbnail;
 }
 public function getPreviewVideoAction()
 {
     $asset = Asset::getById($this->_getParam("id"));
     $this->view->asset = $asset;
     $config = new Asset_Video_Thumbnail_Config();
     $config->setName("pimcore_video_preview_" . $asset->getId());
     $config->setAudioBitrate(128);
     $config->setVideoBitrate(700);
     $config->setItems(array(array("method" => "scaleByWidth", "arguments" => array("width" => 500))));
     $thumbnail = $asset->getThumbnail($config, array("mp4"));
     if ($thumbnail) {
         $this->view->asset = $asset;
         $this->view->thumbnail = $thumbnail;
         if ($thumbnail["status"] == "finished") {
             $this->render("get-preview-video-display");
         } else {
             $this->render("get-preview-video-error");
         }
     } else {
         $this->render("get-preview-video-error");
     }
 }
 public function videoThumbnailUpdateAction()
 {
     $pipe = Asset_Video_Thumbnail_Config::getByName($this->_getParam("name"));
     $data = Zend_Json::decode($this->_getParam("configuration"));
     $items = array();
     foreach ($data as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($pipe, $setter)) {
             $pipe->{$setter}($value);
         }
         if (strpos($key, "item.") === 0) {
             $cleanKeyParts = explode(".", $key);
             $items[$cleanKeyParts[1]][$cleanKeyParts[2]] = $value;
         }
     }
     $pipe->resetItems();
     foreach ($items as $item) {
         $type = $item["type"];
         unset($item["type"]);
         $pipe->addItem($type, $item);
     }
     $pipe->save();
     $this->deleteVideoThumbnailTmpFiles($pipe);
     $this->_helper->json(array("success" => true));
 }