Path: blob/master/src/applications/files/document/PhabricatorAudioDocumentEngine.php
12241 views
<?php12final class PhabricatorAudioDocumentEngine3extends PhabricatorDocumentEngine {45const ENGINEKEY = 'audio';67public function getViewAsLabel(PhabricatorDocumentRef $ref) {8return pht('View as Audio');9}1011protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {12return 'fa-file-sound-o';13}1415protected function getByteLengthLimit() {16return null;17}1819protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {20$file = $ref->getFile();21if ($file) {22return $file->isAudio();23}2425$viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types');26$viewable_types = array_keys($viewable_types);2728$audio_types = PhabricatorEnv::getEnvConfig('files.audio-mime-types');29$audio_types = array_keys($audio_types);3031return32$ref->hasAnyMimeType($viewable_types) &&33$ref->hasAnyMimeType($audio_types);34}3536protected function newDocumentContent(PhabricatorDocumentRef $ref) {37$file = $ref->getFile();38if ($file) {39$source_uri = $file->getViewURI();40} else {41throw new PhutilMethodNotImplementedException();42}4344$mime_type = $ref->getMimeType();4546$audio = phutil_tag(47'audio',48array(49'controls' => 'controls',50),51phutil_tag(52'source',53array(54'src' => $source_uri,55'type' => $mime_type,56)));5758$container = phutil_tag(59'div',60array(61'class' => 'document-engine-audio',62),63$audio);6465return $container;66}6768}697071