46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
class MediaLocalVideo extends MediaRenderer{
|
|
private $id;
|
|
|
|
public function __construct($model){
|
|
$this->id = $model->id;
|
|
}
|
|
|
|
public function asText(array $opt = array()){
|
|
$size = MediaRendererInterface::SIZE_ORIGINAL;
|
|
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES)){
|
|
$size = $opt["size"];
|
|
}
|
|
|
|
$video = $this->getLocalVideoLinkAndType();
|
|
return '<video width="300" height="300" controls >'.
|
|
'<source src="'.$video["path"].'" type="video/'.$video["extension"].'" >'.
|
|
'</video>';
|
|
}
|
|
|
|
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 getLocalVideoLinkAndType(){
|
|
$video = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$this->id));
|
|
|
|
if (!is_null($video)){
|
|
$basepath = GlobalVariables::get("config")->paths->media;
|
|
$videoPath= $basepath."/".$video->id.".".$video->extension;
|
|
|
|
$arr = array();
|
|
$arr["path"] = $videoPath;
|
|
$arr["extension"] = $video->extension;
|
|
return $arr;
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|