public function getAssetCode($inAdmin = false)
{
$asset = Asset::getById($this->id);
$options = $this->getOptions();
// compatibility mode when FFMPEG is not present or no thumbnail config is given
if (!\Pimcore\Video::isAvailable() || !$options["thumbnail"]) {
if ($asset instanceof Asset && preg_match("/\\.(f4v|flv|mp4)/", $asset->getFullPath())) {
return $this->getHtml5Code(["mp4" => (string) $asset]);
}
return $this->getErrorCode("Asset is not a video, or missing thumbnail configuration");
}
if ($asset instanceof Asset\Video && $options["thumbnail"]) {
$thumbnail = $asset->getThumbnail($options["thumbnail"]);
if ($thumbnail) {
if (!array_key_exists("imagethumbnail", $options) || empty($options["imagethumbnail"])) {
// try to get the dimensions out ouf the video thumbnail
$imageThumbnailConf = $asset->getThumbnailConfig($options["thumbnail"])->getEstimatedDimensions();
$imageThumbnailConf["format"] = "JPEG";
} else {
$imageThumbnailConf = $options["imagethumbnail"];
}
if (empty($imageThumbnailConf)) {
$imageThumbnailConf["width"] = 800;
$imageThumbnailConf["format"] = "JPEG";
}
if ($this->poster && ($poster = Asset::getById($this->poster))) {
$image = $poster->getThumbnail($imageThumbnailConf);
} else {
if ($asset->getCustomSetting("image_thumbnail_asset")) {
$image = (string) $asset->getImageThumbnail($imageThumbnailConf);
} else {
$image = (string) $asset->getImageThumbnail($imageThumbnailConf);
}
}
if ($inAdmin && isset($options["editmodeImagePreview"]) && $options["editmodeImagePreview"]) {
$code = '<div id="pimcore_video_' . $this->getName() . '" class="pimcore_tag_video">';
$code .= '<img width="' . $this->getWidth() . '" src="' . $image . '" />';
$code .= '</div>';
return $code;
}
if ($thumbnail["status"] == "finished") {
return $this->getHtml5Code($thumbnail["formats"], $image);
} elseif ($thumbnail["status"] == "inprogress") {
// disable the output-cache if enabled
$front = \Zend_Controller_Front::getInstance();
$front->unregisterPlugin("Pimcore\\Controller\\Plugin\\Cache");
return $this->getProgressCode($image);
} else {
return $this->getErrorCode("The video conversion failed, please see the debug.log for more details.");
}
} else {
return $this->getErrorCode("The given thumbnail doesn't exist: '" . $options["thumbnail"] . "'");
}
} else {
return $this->getEmptyCode();
}
}