@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 75 lines 1.8 kB view raw
1<?php 2 3final class PhabricatorVideoDocumentEngine 4 extends PhabricatorDocumentEngine { 5 6 const ENGINEKEY = 'video'; 7 8 public function getViewAsLabel(PhabricatorDocumentRef $ref) { 9 return pht('View as Video'); 10 } 11 12 protected function getContentScore(PhabricatorDocumentRef $ref) { 13 // Some video documents can be rendered as either video or audio, but we 14 // want to prefer video. 15 return 2500; 16 } 17 18 protected function getByteLengthLimit() { 19 return null; 20 } 21 22 protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 23 return 'fa-film'; 24 } 25 26 protected function canRenderDocumentType(PhabricatorDocumentRef $ref) { 27 $file = $ref->getFile(); 28 if ($file) { 29 return $file->isVideo(); 30 } 31 32 $viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types'); 33 $viewable_types = array_keys($viewable_types); 34 35 $video_types = PhabricatorEnv::getEnvConfig('files.video-mime-types'); 36 $video_types = array_keys($video_types); 37 38 return 39 $ref->hasAnyMimeType($viewable_types) && 40 $ref->hasAnyMimeType($video_types); 41 } 42 43 protected function newDocumentContent(PhabricatorDocumentRef $ref) { 44 $file = $ref->getFile(); 45 if ($file) { 46 $source_uri = $file->getViewURI(); 47 } else { 48 throw new PhutilMethodNotImplementedException(); 49 } 50 51 $mime_type = $ref->getMimeType(); 52 53 $video = phutil_tag( 54 'video', 55 array( 56 'controls' => 'controls', 57 ), 58 phutil_tag( 59 'source', 60 array( 61 'src' => $source_uri, 62 'type' => $mime_type, 63 ))); 64 65 $container = phutil_tag( 66 'div', 67 array( 68 'class' => 'document-engine-video', 69 ), 70 $video); 71 72 return $container; 73 } 74 75}