Path: blob/master/src/applications/files/document/PhabricatorVideoDocumentEngine.php
12241 views
<?php12final class PhabricatorVideoDocumentEngine3extends PhabricatorDocumentEngine {45const ENGINEKEY = 'video';67public function getViewAsLabel(PhabricatorDocumentRef $ref) {8return pht('View as Video');9}1011protected function getContentScore(PhabricatorDocumentRef $ref) {12// Some video documents can be rendered as either video or audio, but we13// want to prefer video.14return 2500;15}1617protected function getByteLengthLimit() {18return null;19}2021protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {22return 'fa-film';23}2425protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {26$file = $ref->getFile();27if ($file) {28return $file->isVideo();29}3031$viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types');32$viewable_types = array_keys($viewable_types);3334$video_types = PhabricatorEnv::getEnvConfig('files.video-mime-types');35$video_types = array_keys($video_types);3637return38$ref->hasAnyMimeType($viewable_types) &&39$ref->hasAnyMimeType($video_types);40}4142protected function newDocumentContent(PhabricatorDocumentRef $ref) {43$file = $ref->getFile();44if ($file) {45$source_uri = $file->getViewURI();46} else {47throw new PhutilMethodNotImplementedException();48}4950$mime_type = $ref->getMimeType();5152$video = phutil_tag(53'video',54array(55'controls' => 'controls',56),57phutil_tag(58'source',59array(60'src' => $source_uri,61'type' => $mime_type,62)));6364$container = phutil_tag(65'div',66array(67'class' => 'document-engine-video',68),69$video);7071return $container;72}7374}757677