49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php
|
|
|
|
class MediaLocalVideo extends MediaRenderer{
|
|
private $id;
|
|
|
|
public function __construct($model){
|
|
$this->id = $model->id;
|
|
}
|
|
|
|
public function asText(array $opt = array()){
|
|
$size = self::$SIZES[self::SIZE_BIG];
|
|
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES) && $opt["size"] != self::SIZE_ORIGINAL){
|
|
$size = self::$SIZES[$opt["size"]];
|
|
}
|
|
|
|
$loaderSize = self::$SIZES[self::SIZE_BIG];
|
|
$hideControls = array_key_exists("hideControls", $opt) && $opt["hideControls"]===true;
|
|
|
|
return '<div style="position:relative;" class="videoContainerForImageAppend"><img class="poster" src="'.GUIHandler::getBaseUrl().'/images/loading.gif" style="width:'.$loaderSize["width"].'px;height:'.$loaderSize["height"].'px;" />'.
|
|
'<video class="localVideo" width="'.$size["width"].'" preload="auto" '.($hideControls?"":"controls").' style="visibility:hidden;">'.
|
|
// '<source src="'.$this->getVideoLink($size).'" type=\'video/'.$this->getExtension().'; codecs="avc1.4D401E, mp4a.40.2"\'>'.
|
|
'<source src="'.$this->getVideoLink($size).'" >'.
|
|
'</video></div>';
|
|
|
|
}
|
|
|
|
public function render(array $opt = array()){
|
|
echo $this->asText($opt);
|
|
}
|
|
|
|
public function getPath(){
|
|
$basepath = GlobalVariables::get("config")->paths->media;
|
|
return $basepath."/".$this->id.".".$this->extension;
|
|
}
|
|
|
|
public function getExtension(){
|
|
$video = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$this->id));
|
|
return $video->extension;
|
|
}
|
|
|
|
public function getVideoLink($size){
|
|
if(!array_key_exists($size, self::$SIZES)){
|
|
$size = MediaRendererInterface::SIZE_ORIGINAL;
|
|
}
|
|
return GUIHandler::getBaseUrl().'getLocalVideo.php?id='.$this->id.'&size='.$size;
|
|
}
|
|
|
|
}
|
|
?>
|